public class PredicatedList<E> extends PredicatedCollection<E> implements java.util.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,
java.util.Collection<? extends E> coll) |
boolean |
equals(java.lang.Object object) |
E |
get(int index) |
int |
hashCode() |
int |
indexOf(java.lang.Object object) |
int |
lastIndexOf(java.lang.Object object) |
java.util.ListIterator<E> |
listIterator() |
java.util.ListIterator<E> |
listIterator(int i) |
static <T> PredicatedList<T> |
predicatedList(java.util.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) |
java.util.List<E> |
subList(int fromIndex,
int toIndex) |
add, addAll, builder, notNullBuilder, predicatedCollection
clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray, toString
public static <T> PredicatedList<T> predicatedList(java.util.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 nulljava.lang.NullPointerException
- if list or predicate is nulljava.lang.IllegalArgumentException
- if the list contains invalid elementspublic boolean equals(java.lang.Object object)
public int hashCode()
public int indexOf(java.lang.Object object)
indexOf
in interface java.util.List<E>
public int lastIndexOf(java.lang.Object object)
lastIndexOf
in interface java.util.List<E>
public boolean addAll(int index, java.util.Collection<? extends E> coll)
addAll
in interface java.util.List<E>
public java.util.ListIterator<E> listIterator()
listIterator
in interface java.util.List<E>
public java.util.ListIterator<E> listIterator(int i)
listIterator
in interface java.util.List<E>
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"