public class PredicatedList<E> extends PredicatedCollection<E> implements List<E>
List to 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<String> list =
PredicatedList.predicatedList(new ArrayList<String>(), PredicateUtils.notNullPredicate());
This class is Serializable from Commons Collections 3.1.
PredicatedCollection.Builder<E>| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
E object) |
boolean |
addAll(int index,
Collection<? extends E> coll) |
boolean |
equals(Object object) |
E |
get(int index) |
int |
hashCode() |
int |
indexOf(Object object) |
int |
lastIndexOf(Object object) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int i) |
static <T> PredicatedList<T> |
predicatedList(List<T> list,
Predicate<? super T> predicate)
Factory method to create a predicated (validating) list.
|
E |
remove(int index) |
E |
set(int index,
E object) |
List<E> |
subList(int fromIndex,
int toIndex) |
add, addAll, builder, notNullBuilder, predicatedCollectionclear, contains, containsAll, isEmpty, iterator, remove, removeAll, removeIf, retainAll, size, toArray, toArray, toStringadd, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, replaceAll, retainAll, size, sort, spliterator, toArray, toArrayparallelStream, removeIf, streampublic static <T> PredicatedList<T> predicatedList(List<T> list, Predicate<? super T> predicate)
If there are any elements already in the list being decorated, they are validated.
T - the type of the elements in the listlist - the list to decorate, must not be nullpredicate - the predicate to use for validation, must not be nullNullPointerException - if list or predicate is nullIllegalArgumentException - if the list contains invalid elementspublic boolean equals(Object object)
public int hashCode()
public int lastIndexOf(Object object)
lastIndexOf in interface List<E>public boolean addAll(int index,
Collection<? extends E> coll)
public ListIterator<E> listIterator()
listIterator in interface List<E>public ListIterator<E> listIterator(int i)
listIterator in interface List<E>Copyright © 2010 - 2020 Adobe. All Rights Reserved