From dc9032be284c70f53d8f9031cc90e01678a0e55f Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 11 Oct 2018 17:49:35 -0600 Subject: [PATCH] Refactor common code into a private method. --- .../collections4/list/FixedSizeList.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java b/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java index f86ebb310..bca2e46b8 100644 --- a/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java +++ b/src/main/java/org/apache/commons/collections4/list/FixedSizeList.java @@ -75,27 +75,27 @@ public class FixedSizeList //----------------------------------------------------------------------- @Override public boolean add(final E object) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public void add(final int index, final E object) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public boolean addAll(final Collection coll) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public boolean addAll(final int index, final Collection coll) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public void clear() { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override @@ -130,22 +130,22 @@ public class FixedSizeList @Override public E remove(final int index) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public boolean remove(final Object object) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public boolean removeAll(final Collection coll) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public boolean retainAll(final Collection coll) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override @@ -168,11 +168,11 @@ public class FixedSizeList } @Override public void remove() { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } @Override public void add(final Object object) { - throw new UnsupportedOperationException("List is fixed size"); + throw unsupportedOperationException(); } } @@ -186,4 +186,8 @@ public class FixedSizeList return size(); } + private static UnsupportedOperationException unsupportedOperationException() { + return new UnsupportedOperationException("List is fixed size"); + } + }