Class FixedSizeList
- java.lang.Object
-
- org.apache.commons.collections.collection.AbstractCollectionDecorator
-
- org.apache.commons.collections.list.AbstractListDecorator
-
- org.apache.commons.collections.list.AbstractSerializableListDecorator
-
- org.apache.commons.collections.list.FixedSizeList
-
- All Implemented Interfaces:
Serializable,Iterable,Collection,List,BoundedCollection
public class FixedSizeList extends AbstractSerializableListDecorator implements BoundedCollection
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).
This class is Serializable from Commons Collections 3.1.
- Since:
- Commons Collections 3.0
- Version:
- $Revision: 646777 $ $Date: 2008-04-10 14:33:15 +0200 (Thu, 10 Apr 2008) $
- Author:
- Stephen Colebourne, Paul Jack
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator
collection
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFixedSizeList(List list)Constructor that wraps (not copies).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Object object)booleanadd(Object object)booleanaddAll(int index, Collection coll)booleanaddAll(Collection coll)voidclear()static Listdecorate(List list)Factory method to create a fixed size list.Objectget(int index)intindexOf(Object object)booleanisFull()Returns true if this collection is full and no new elements can be added.Iteratoriterator()intlastIndexOf(Object object)ListIteratorlistIterator()ListIteratorlistIterator(int index)intmaxSize()Gets the maximum size of the collection (the bound).Objectremove(int index)booleanremove(Object object)booleanremoveAll(Collection coll)booleanretainAll(Collection coll)Objectset(int index, Object object)ListsubList(int fromIndex, int toIndex)-
Methods inherited from class org.apache.commons.collections.list.AbstractListDecorator
getList
-
Methods inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator
contains, containsAll, equals, getCollection, hashCode, isEmpty, size, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
Methods inherited from interface java.util.List
contains, containsAll, equals, hashCode, isEmpty, replaceAll, size, sort, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
FixedSizeList
protected FixedSizeList(List list)
Constructor that wraps (not copies).- Parameters:
list- the list to decorate, must not be null- Throws:
IllegalArgumentException- if list is null
-
-
Method Detail
-
decorate
public static List decorate(List list)
Factory method to create a fixed size list.- Parameters:
list- the list to decorate, must not be null- Throws:
IllegalArgumentException- if list is null
-
add
public boolean add(Object object)
- Specified by:
addin interfaceCollection- Specified by:
addin interfaceList- Overrides:
addin classAbstractCollectionDecorator
-
add
public void add(int index, Object object)- Specified by:
addin interfaceList- Overrides:
addin classAbstractListDecorator
-
addAll
public boolean addAll(Collection coll)
- Specified by:
addAllin interfaceCollection- Specified by:
addAllin interfaceList- Overrides:
addAllin classAbstractCollectionDecorator
-
addAll
public boolean addAll(int index, Collection coll)- Specified by:
addAllin interfaceList- Overrides:
addAllin classAbstractListDecorator
-
clear
public void clear()
- Specified by:
clearin interfaceCollection- Specified by:
clearin interfaceList- Overrides:
clearin classAbstractCollectionDecorator
-
get
public Object get(int index)
- Specified by:
getin interfaceList- Overrides:
getin classAbstractListDecorator
-
indexOf
public int indexOf(Object object)
- Specified by:
indexOfin interfaceList- Overrides:
indexOfin classAbstractListDecorator
-
iterator
public Iterator iterator()
- Specified by:
iteratorin interfaceCollection- Specified by:
iteratorin interfaceIterable- Specified by:
iteratorin interfaceList- Overrides:
iteratorin classAbstractCollectionDecorator
-
lastIndexOf
public int lastIndexOf(Object object)
- Specified by:
lastIndexOfin interfaceList- Overrides:
lastIndexOfin classAbstractListDecorator
-
listIterator
public ListIterator listIterator()
- Specified by:
listIteratorin interfaceList- Overrides:
listIteratorin classAbstractListDecorator
-
listIterator
public ListIterator listIterator(int index)
- Specified by:
listIteratorin interfaceList- Overrides:
listIteratorin classAbstractListDecorator
-
remove
public Object remove(int index)
- Specified by:
removein interfaceList- Overrides:
removein classAbstractListDecorator
-
remove
public boolean remove(Object object)
- Specified by:
removein interfaceCollection- Specified by:
removein interfaceList- Overrides:
removein classAbstractCollectionDecorator
-
removeAll
public boolean removeAll(Collection coll)
- Specified by:
removeAllin interfaceCollection- Specified by:
removeAllin interfaceList- Overrides:
removeAllin classAbstractCollectionDecorator
-
retainAll
public boolean retainAll(Collection coll)
- Specified by:
retainAllin interfaceCollection- Specified by:
retainAllin interfaceList- Overrides:
retainAllin classAbstractCollectionDecorator
-
set
public Object set(int index, Object object)
- Specified by:
setin interfaceList- Overrides:
setin classAbstractListDecorator
-
subList
public List subList(int fromIndex, int toIndex)
- Specified by:
subListin interfaceList- Overrides:
subListin classAbstractListDecorator
-
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- 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- Returns:
- the maximum number of elements the collection can hold
-
-