Package eu.bandm.tools.util.nonnull
Interface NonNullList<T>
- All Superinterfaces:
Collection<T>,Iterable<T>,List<T>,SequencedCollection<T>
- All Known Implementing Classes:
NonNullList.ListProxy
Implements a list which is strict in all its elements.
The implementation is done by delegation to some peer object from a
predefined Java runtime class.
Optional operations are supported whenever the peer object supports them.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classInternal proxy which inserts the checks for non-null into all state-changing methods.static class -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <T2> NonNullList<T2> Creates a new instance and uses the data from the given list.static <T2> NonNullList<T2> Creates a new instance and uses aArrayListas its peer.static <T2> NonNullList<T2> newInstance(Supplier<List<T2>> supplier) Creates a new instance and uses a list returned by the given supplier as its peer.static <T> NonNullList<T> singleton(T x) Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.List
add, add, addAll, addAll, addFirst, addLast, clear, contains, containsAll, equals, get, getFirst, getLast, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeFirst, removeLast, replaceAll, retainAll, reversed, set, size, sort, spliterator, subList, toArray, toArray
-
Method Details
-
newInstance
Creates a new instance and uses aArrayListas its peer. -
newInstance
Creates a new instance and uses a list returned by the given supplier as its peer.- Parameters:
supplier- must deliver an empty instance of the intended peer class.- Throws:
IllegalArgumentException- if the delivered peer is not empty.
-
copyOf
Creates a new instance and uses the data from the given list. UsesCollections.duplicate(List)to create a copy with similar behaviour, to be used as peer.- Parameters:
proto- the data for the new list- Throws:
NullPointerException- if the data contains null values.
-
singleton
-