Package com.yahoo.collections
Class AbstractFilteringList<Type,ListType extends AbstractFilteringList<Type,ListType>>
- java.lang.Object
-
- com.yahoo.collections.AbstractFilteringList<Type,ListType>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractFilteringList(Collection<? extends Type> items, boolean negate, BiFunction<List<Type>,Boolean,ListType> constructor)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ListType
and(ListType others)
Returns the union of the two lists.List<Type>
asList()
Returns the items in this as an immutable list.Set<Type>
asSet()
Returns the items in this as a set.ListType
concat(ListType others)
Deprecated.use and(others)Optional<Type>
first()
Returns the first item in this list, or empty if there are none.ListType
first(int n)
Returns the first n items in this list, or everything except those if negated.<OtherType>
Map<OtherType,ListType>groupingBy(Function<Type,OtherType> classifier)
Returns the items grouped by the given classifier.ListType
in(ListType others)
Returns the subset of items in this which are (not) present in the other list.boolean
isEmpty()
Iterator<Type>
iterator()
<OtherType>
List<OtherType>mapToList(Function<Type,OtherType> mapper)
Returns the items in this as an immutable list after mapping with the given function.ListType
matching(Predicate<Type> condition)
Returns a new list which is the result of filtering with the -- possibly negated -- condition.ListType
not()
Negates the next filter operation.ListType
shuffle(Random random)
Returns the items in this shuffled using random as source of randomnessint
size()
ListType
sortedBy(Comparator<? super Type> comparator)
Returns the items sorted by the given comparator.Spliterator<Type>
spliterator()
-
-
-
Constructor Detail
-
AbstractFilteringList
protected AbstractFilteringList(Collection<? extends Type> items, boolean negate, BiFunction<List<Type>,Boolean,ListType> constructor)
-
-
Method Detail
-
not
public final ListType not()
Negates the next filter operation. All other operations which return a new list reset this modifier.
-
matching
public final ListType matching(Predicate<Type> condition)
Returns a new list which is the result of filtering with the -- possibly negated -- condition.
-
first
public ListType first(int n)
Returns the first n items in this list, or everything except those if negated.
-
first
public Optional<Type> first()
Returns the first item in this list, or empty if there are none.
-
in
public ListType in(ListType others)
Returns the subset of items in this which are (not) present in the other list.
-
concat
@Deprecated public ListType concat(ListType others)
Deprecated.use and(others)
-
mapToList
public final <OtherType> List<OtherType> mapToList(Function<Type,OtherType> mapper)
Returns the items in this as an immutable list after mapping with the given function.
-
sortedBy
public final ListType sortedBy(Comparator<? super Type> comparator)
Returns the items sorted by the given comparator.
-
groupingBy
public final <OtherType> Map<OtherType,ListType> groupingBy(Function<Type,OtherType> classifier)
Returns the items grouped by the given classifier.
-
isEmpty
public final boolean isEmpty()
-
size
public final int size()
-
spliterator
public Spliterator<Type> spliterator()
- Specified by:
spliterator
in interfaceIterable<Type>
-
-