@Override public List<E> subList(final int fromIndex, final int toIndex) { final List<E> sub = decorated().subList(fromIndex, toIndex); return new FixedSizeList<>(sub); }
/** * Returns a fixed-sized list backed by the given list. * Elements may not be added or removed from the returned list, but * existing elements can be changed (for instance, via the * {@link List#set(int, Object)} method). * * @param <E> the element type * @param list the list whose size to fix, must not be null * @return a fixed-size list backed by that list * @throws NullPointerException if the List is null */ public static <E> List<E> fixedSizeList(final List<E> list) { return FixedSizeList.fixedSizeList(list); }
@Override public int maxSize() { return size(); }
@Override public int indexOf(final Object object) { return decorated().indexOf(object); }
/** * Factory method to create a fixed size list. * * @param <E> the type of the elements in the list * @param list the list to decorate, must not be null * @return a new fixed size list * @throws NullPointerException if list is null * @since 4.0 */ public static <E> FixedSizeList<E> fixedSizeList(final List<E> list) { return new FixedSizeList<>(list); }
@Override public E set(final int index, final E object) { return decorated().set(index, object); }
@Override public int lastIndexOf(final Object object) { return decorated().lastIndexOf(object); }
@Override public E get(final int index) { return decorated().get(index); }
@Override public ListIterator<E> listIterator(final int index) { return new FixedSizeListIterator(decorated().listIterator(index)); }
@Override public Iterator<E> iterator() { return UnmodifiableIterator.unmodifiableIterator(decorated().iterator()); }
@Override public ListIterator<E> listIterator() { return new FixedSizeListIterator(decorated().listIterator(0)); }