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 Details

  • Method Details

    • 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.
    • and

      public ListType and(ListType others)
      Returns the concatenation of the two lists.
    • asList

      public final List<Type> asList()
      Returns the items in this as an immutable list.
    • asSet

      public final Set<Type> asSet()
      Returns the items in this as a set.
    • 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()
    • iterator

      public Iterator<Type> iterator()
      Specified by:
      iterator in interface Iterable<Type>
    • spliterator

      public Spliterator<Type> spliterator()
      Specified by:
      spliterator in interface Iterable<Type>
    • shuffle

      public final ListType shuffle(Random random)
      Returns the items in this shuffled using random as source of randomness