Class PredicatedList
- java.lang.Object
-
- org.apache.commons.collections.collection.AbstractCollectionDecorator
-
- org.apache.commons.collections.collection.AbstractSerializableCollectionDecorator
-
- org.apache.commons.collections.collection.PredicatedCollection
-
- org.apache.commons.collections.list.PredicatedList
-
- All Implemented Interfaces:
Serializable,Iterable,Collection,List
@Deprecated(since="2021-04-30") public class PredicatedList extends PredicatedCollection implements List
Deprecated.Commons Collections 3 is in maintenance mode. Commons Collections 4 should be used instead.Decorates anotherListto validate that all additions match a specified predicate.This list exists to provide validation for the decorated list. It is normally created to decorate an empty list. If an object cannot be added to the list, an IllegalArgumentException is thrown.
One usage would be to ensure that no null entries are added to the list.
List list = PredicatedList.decorate(new ArrayList(), NotNullPredicate.INSTANCE);
This class is Serializable from Commons Collections 3.1.
- Since:
- Commons Collections 3.0
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(int index, Object object)Deprecated.booleanaddAll(int index, Collection coll)Deprecated.static Listdecorate(List list, Predicate predicate)Deprecated.Factory method to create a predicated (validating) list.Objectget(int index)Deprecated.intindexOf(Object object)Deprecated.intlastIndexOf(Object object)Deprecated.ListIteratorlistIterator()Deprecated.ListIteratorlistIterator(int i)Deprecated.Objectremove(int index)Deprecated.Objectset(int index, Object object)Deprecated.ListsubList(int fromIndex, int toIndex)Deprecated.-
Methods inherited from class org.apache.commons.collections.collection.PredicatedCollection
add, addAll, decorate
-
Methods inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator
clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Method Detail
-
decorate
public static List decorate(List list, Predicate predicate)
Deprecated.Factory method to create a predicated (validating) list.If there are any elements already in the list being decorated, they are validated.
- Parameters:
list- the list to decorate, must not be nullpredicate- the predicate to use for validation, must not be null- Throws:
IllegalArgumentException- if list or predicate is nullIllegalArgumentException- if the list contains invalid elements
-
lastIndexOf
public int lastIndexOf(Object object)
Deprecated.- Specified by:
lastIndexOfin interfaceList
-
addAll
public boolean addAll(int index, Collection coll)Deprecated.
-
listIterator
public ListIterator listIterator()
Deprecated.- Specified by:
listIteratorin interfaceList
-
listIterator
public ListIterator listIterator(int i)
Deprecated.- Specified by:
listIteratorin interfaceList
-
-