Class FixedSizeList<E>
- java.lang.Object
-
- org.apache.commons.collections4.collection.AbstractCollectionDecorator<E>
-
- org.apache.commons.collections4.list.AbstractListDecorator<E>
-
- org.apache.commons.collections4.list.AbstractSerializableListDecorator<E>
-
- org.apache.commons.collections4.list.FixedSizeList<E>
-
- Type Parameters:
E- the type of elements in this collection
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>,BoundedCollection<E>
public class FixedSizeList<E> extends AbstractSerializableListDecorator<E> implements BoundedCollection<E>
Decorates anotherListto fix the size preventing add/remove.The add, remove, clear and retain operations are unsupported. The set method is allowed (as it doesn't change the list size).
NOTE: Modifying the decorated list directly would results in influencing the outcome of method calls on this object. For example, the bounds of this list would reflect a newly added object to the underlying list.
This class is Serializable from Commons Collections 3.1.
- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E object)booleanadd(E object)booleanaddAll(int index, Collection<? extends E> coll)booleanaddAll(Collection<? extends E> coll)voidclear()static <E> FixedSizeList<E>fixedSizeList(List<E> list)Factory method to create a fixed size list.Eget(int index)intindexOf(Object object)booleanisFull()Returns true if this collection is full and no new elements can be added.Iterator<E>iterator()intlastIndexOf(Object object)ListIterator<E>listIterator()ListIterator<E>listIterator(int index)intmaxSize()Gets the maximum size of the collection (the bound).Eremove(int index)booleanremove(Object object)booleanremoveAll(Collection<?> coll)booleanremoveIf(Predicate<? super E> filter)booleanretainAll(Collection<?> coll)Eset(int index, E object)List<E>subList(int fromIndex, int toIndex)-
Methods inherited from class org.apache.commons.collections4.list.AbstractListDecorator
equals, hashCode
-
Methods inherited from class org.apache.commons.collections4.collection.AbstractCollectionDecorator
contains, containsAll, isEmpty, size, toArray, toArray, toString
-
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Methods inherited from interface java.util.List
contains, containsAll, isEmpty, replaceAll, size, sort, spliterator, toArray, toArray
-
-
-
-
Method Detail
-
fixedSizeList
public static <E> FixedSizeList<E> fixedSizeList(List<E> list)
Factory method to create a fixed size list.- Type Parameters:
E- the type of the elements in the list- Parameters:
list- the list to decorate, must not be null- Returns:
- a new fixed size list
- Throws:
NullPointerException- if list is null- Since:
- 4.0
-
add
public boolean add(E object)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractCollectionDecorator<E>
-
add
public void add(int index, E object)
-
addAll
public boolean addAll(Collection<? extends E> coll)
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractCollectionDecorator<E>
-
addAll
public boolean addAll(int index, Collection<? extends E> coll)
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classAbstractCollectionDecorator<E>
-
get
public E get(int index)
-
indexOf
public int indexOf(Object object)
-
lastIndexOf
public int lastIndexOf(Object object)
- Specified by:
lastIndexOfin interfaceList<E>- Overrides:
lastIndexOfin classAbstractListDecorator<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classAbstractListDecorator<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classAbstractListDecorator<E>
-
remove
public E remove(int index)
-
remove
public boolean remove(Object object)
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractCollectionDecorator<E>
-
removeIf
public boolean removeIf(Predicate<? super E> filter)
- Specified by:
removeIfin interfaceCollection<E>- Overrides:
removeIfin classAbstractCollectionDecorator<E>- Since:
- 4.4
-
removeAll
public boolean removeAll(Collection<?> coll)
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractCollectionDecorator<E>
-
retainAll
public boolean retainAll(Collection<?> coll)
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classAbstractCollectionDecorator<E>
-
isFull
public boolean isFull()
Description copied from interface:BoundedCollectionReturns true if this collection is full and no new elements can be added.- Specified by:
isFullin interfaceBoundedCollection<E>- Returns:
trueif the collection is full.
-
maxSize
public int maxSize()
Description copied from interface:BoundedCollectionGets the maximum size of the collection (the bound).- Specified by:
maxSizein interfaceBoundedCollection<E>- Returns:
- the maximum number of elements the collection can hold.
-
-