Refactor common code into a private method.

This commit is contained in:
Gary Gregory 2018-10-11 17:49:35 -06:00
parent 74ad211470
commit dc9032be28
1 changed files with 15 additions and 11 deletions

View File

@ -75,27 +75,27 @@ public class FixedSizeList<E>
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
@Override @Override
public boolean add(final E object) { public boolean add(final E object) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public void add(final int index, final E object) { public void add(final int index, final E object) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public boolean addAll(final Collection<? extends E> coll) { public boolean addAll(final Collection<? extends E> coll) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public boolean addAll(final int index, final Collection<? extends E> coll) { public boolean addAll(final int index, final Collection<? extends E> coll) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public void clear() { public void clear() {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
@ -130,22 +130,22 @@ public class FixedSizeList<E>
@Override @Override
public E remove(final int index) { public E remove(final int index) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public boolean remove(final Object object) { public boolean remove(final Object object) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public boolean removeAll(final Collection<?> coll) { public boolean removeAll(final Collection<?> coll) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public boolean retainAll(final Collection<?> coll) { public boolean retainAll(final Collection<?> coll) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
@ -168,11 +168,11 @@ public class FixedSizeList<E>
} }
@Override @Override
public void remove() { public void remove() {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
@Override @Override
public void add(final Object object) { public void add(final Object object) {
throw new UnsupportedOperationException("List is fixed size"); throw unsupportedOperationException();
} }
} }
@ -186,4 +186,8 @@ public class FixedSizeList<E>
return size(); return size();
} }
private static UnsupportedOperationException unsupportedOperationException() {
return new UnsupportedOperationException("List is fixed size");
}
} }