Package com.yahoo.collections
Class AbstractFilteringList<Type,ListType extends AbstractFilteringList<Type,ListType>>
java.lang.Object
com.yahoo.collections.AbstractFilteringList<Type,ListType>
- All Implemented Interfaces:
Iterable<Type>
public abstract class AbstractFilteringList<Type,ListType extends AbstractFilteringList<Type,ListType>>
extends Object
implements Iterable<Type>
Abstract, immutable list for subclassing with concrete types and domain specific filters.
- Author:
- jonmv
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractFilteringList
(Collection<? extends Type> items, boolean negate, BiFunction<List<Type>, Boolean, ListType> constructor) -
Method Summary
Modifier and TypeMethodDescriptionReturns the concatenation of the two lists.asList()
Returns the items in this as an immutable list.asSet()
Returns the items in this as a set.first()
Returns the first item in this list, or empty if there are none.first
(int n) Returns the first n items in this list, or everything except those if negated.groupingBy
(Function<Type, OtherType> classifier) Returns the items grouped by the given classifier.Returns the subset of items in this which are (not) present in the other list.final boolean
isEmpty()
iterator()
final <OtherType>
List<OtherType>Returns the items in this as an immutable list after mapping with the given function.final ListType
Returns a new list which is the result of filtering with the -- possibly negated -- condition.final ListType
not()
Negates the next filter operation.final ListType
Returns the items in this shuffled using random as source of randomnessfinal int
size()
final ListType
sortedBy
(Comparator<? super Type> comparator) Returns the items sorted by the given comparator.
-
Constructor Details
-
AbstractFilteringList
protected AbstractFilteringList(Collection<? extends Type> items, boolean negate, BiFunction<List<Type>, Boolean, ListType> constructor)
-
-
Method Details
-
not
Negates the next filter operation. All other operations which return a new list reset this modifier. -
matching
Returns a new list which is the result of filtering with the -- possibly negated -- condition. -
first
Returns the first n items in this list, or everything except those if negated. -
first
Returns the first item in this list, or empty if there are none. -
in
Returns the subset of items in this which are (not) present in the other list. -
and
Returns the concatenation of the two lists. -
asList
Returns the items in this as an immutable list. -
asSet
Returns the items in this as a set. -
mapToList
Returns the items in this as an immutable list after mapping with the given function. -
sortedBy
Returns the items sorted by the given comparator. -
groupingBy
Returns the items grouped by the given classifier. -
isEmpty
public final boolean isEmpty() -
size
public final int size() -
iterator
-
spliterator
- Specified by:
spliterator
in interfaceIterable<Type>
-
shuffle
Returns the items in this shuffled using random as source of randomness
-