Interface Queriable<T>

Type Parameters:
T - Type of elements
All Superinterfaces:
Iterable<T>
All Known Subinterfaces:
GroupedQueriable<T>, OrderedGroupedQueriable<T>, OrderedQueriable<T>

public interface Queriable<T> extends Iterable<T>
An Iterable which can be queried
Author:
René Bergelt
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    all​(Predicate<T> predicate)
    Return if all elements in the enumeration fulfill the given predicate
    Return the average from the enumeration (Elements will be cast to java.lang.Number)
    average​(NumberFunc<T> valFunc)
    Return the average from the enumeration where the value for each item is calculated by the given function
    <TOut> Queriable<TOut>
    cast​(Class<TOut> targetType)
    Cast each element of the enumeration to the given type and return an enumeration of this type (This is an unchecked cast, so if any element in the enumeration cannot be cast to the given type an exception will be thrown)
    concat​(Iterable<T> toConcat)
    Return an enumeration which contains all elements of the current enumeration and all elements of the enumeration given as argument
    boolean
    contains​(T element)
    Returns if this enumeration contains the given element (Equality is checked using Object.equals())
    boolean
    contains​(T element, Equivalence<T> equalityComparer)
    Returns if this enumeration contains the given element (Equality is checked using the given Equivalence function)
    int
    Return the amount of elements in the enumeration if it is finite
    int
    count​(Predicate<T> predicate)
    Return the amount of elements in the (finite) enumeration which satisfy the given predicate This is basically the same as .where(predicate).count()
    defaultIfEmpty​(T defaultValue)
    Returns this enumeration itself if it contains any elements or if it is empty an enumeration only containing the given defaultElement
    Returns an enumeration where each item of the enumeration appears exactly once (Equality is checked using the equals(...) method)
    distinct​(Equivalence<T> equalityComparer)
    Returns an enumeration where each item of the enumeration appears exactly once (Equality is checked using the given equalityComparer)
    elementAt​(int index)
    Return the element at the given position or throw NoSuchElementException if no element at this index exits (i.e. the enumeration contains less than (index+1) elements)
    elementAtOrDefault​(int index)
    Return the element at the given position or return null if no element at this index exits (i.e. the enumeration contains less than (index+1) elements)
    elementAtOrDefault​(int index, T defaultValue)
    Return the element at the given position or return the given default value if no element at this index exits (i.e. the enumeration contains less than (index+1) elements)
    except​(Iterable<T> elementsToSubtract)
    Returns an iterable which contains only the elements of this enumeration which do not exist in the given Iterable (Equality is checked using the equals(...) method)
    except​(Iterable<T> elementsToSubtract, Equivalence<T> equalityComparer)
    Returns an iterable which contains only the elements of this enumeration which do not exist in the given Iterable (Equality is checked using the given equalityComparer)
    boolean
    exists​(Predicate<T> predicate)
    Test if at least one element of the enumeration fulfills the condition
    Return the first element of the enumeration or throw NoSuchElementException if the enumeration is empty
    first​(Predicate<T> predicate)
    Return the first element of the enumeration for which the predicate is true or throw NoSuchElementException if no corresponding element exists
    Return the first element of the enumeration or null if the enumeration is empty
    firstOrDefault​(Predicate<T> predicate)
    Return the first element in the enumeration for which the predicate is true or null if no corresponding element exists
    firstOrDefault​(Predicate<T> predicate, T defaultValue)
    Return the first element in the enumeration for which the predicate is true or the given default value if no corresponding element exists
    firstOrDefault​(T defaultValue)
    Return the first element of the enumeration or the passed defaultValue if the enumeration is empty
    group​(GroupFunction<T> func)
    Groups the elements of the enumeration according to the given grouping function
    Groups the elements of the enumeration according to the given grouping function (Convenience function for grouping with only one group key element)
    intersect​(Iterable<T> intersectWith)
    Returns an iterable which contains the elements of this enumeration which also exist in the given Iterable (Equality is checked using the equals(...) method)
    intersect​(Iterable<T> intersectWith, Equivalence<T> equalityComparer)
    Returns an iterable which contains the elements of this enumeration which also exist in the given Iterable (Equality is checked using the given equalityComparer)
    boolean
    Return if the enumeration is empty
    Return the last element of the enumeration or throw NoSuchElementException if the enumeration is empty
    last​(Predicate<T> predicate)
    Return the last element of the enumeration for which the predicate is true or throw NoSuchElementException if no corresponding element exists
    Return the last element of the enumeration or null if the list is empty
    lastOrDefault​(Predicate<T> predicate)
    Return the last element in the enumeration for which the predicate is true or null if no corresponding element exists This is basically the same as .where(predicate).lastOrDefault()
    lastOrDefault​(Predicate<T> predicate, T defaultValue)
    Return the last element in the enumeration for which the predicate is true or the given default value if no corresponding element exists This is basically the same as .where(predicate).lastOrDefault()
    max()
    Returns the maximum element of the enumeration (Elements have to implement Comparable)
    max​(NumberFunc<T> valFunc)
    Return the maximum from the enumeration where the value for each item is calculated by the given function
    min()
    Returns the minimum element of the enumeration (Elements have to implement Comparable)
    min​(NumberFunc<T> valFunc)
    Return the minimum from the enumeration where the value for each item is calculated by the given function*
    <TOut> Queriable<TOut>
    ofType​(Class<TOut> targetType)
    Return the elements of the enumeration which are of the requested type or can be cast to it
    Order the elements of this enumeration according to the values returned by the order function
    <TComparable>
    OrderedQueriable<T>
    orderBy​(ItemFunc<T,​TComparable> valueFunc, Comparator<TComparable> comparator)
    Order the elements of this enumeration according to the values returned by the value function function using the given comparator
    Order the elements of this enumeration according the values returned by the order function in descending order
    <TComparable>
    OrderedQueriable<T>
    orderByDescending​(ItemFunc<T,​TComparable> valueFunc, Comparator<TComparable> comparator)
    Order the elements of this enumeration according to the values returned by the value function function using the given comparator in descending order
    Reverse the order of elements of this enumeration
    <TOut> Queriable<TOut>
    select​(Selector<T,​TOut> selector)
    Transforms each element of the enumeration using a selector
    <TOut> Queriable<TOut>
    selectMany​(Selector<T,​Iterable<TOut>> selector)
    Transform each element of the enumeration into another enumeration and combine all results to a single list
    boolean
    sequenceEquals​(Iterable<T> iterable)
    Checks whether this enumeration and the given iterable contain the same elements and the same position and have the same length (Equality is checked using Object.equals())
    boolean
    sequenceEquals​(Iterable<T> iterable, Equivalence<T> equalityComparer)
    Checks whether this enumeration and the given iterable contain the same elements and the same position and have the same length (Equality is checked using the given custom Equivalence comparer)
    If the iterable contains only one element return this element.
    single​(Predicate<T> predicate)
    If the iterable contains only one element which satisfies the condition return this element.
    If the iterable contains only one element return this element.
    singleOrDefault​(Predicate<T> predicate)
    If the iterable contains only one element which satisfies the condition return this element.
    skip​(int amount)
    Skip the given amount of elements in the list and return a Queriable which starts at the (amount+1)th element or is empty if the enumeration did not contain more than amount elements
    skipWhile​(Predicate<T> condition)
    Return a queriable which starts at the first element of the enumeration which does not satisfy the condition, if no such element exists the returned Queriable is empty
    sum()
    Return the sum from the enumeration where the value for each item (Elements will be cast to java.lang.Number)
    sum​(NumberFunc<T> valFunc)
    Return the sum from the enumeration where the value for each item is calculated by the given function
    take​(int amount)
    Take the given amount of elements from the enumeration or take elements until the enumeration ends
    takeWhile​(Predicate<T> condition)
    Take elements from the enumeration as long as they satisfy the condition or until the enumeration ends
    T[]
    toArray​(Class<T> classType)
    Return an array which contains all elements of this enumeration (This will evaluate the whole enumeration, if it is infinite this will block forever.)
    Return a list which contains all elements of this enumeration (This will evaluate the whole enumeration, if it is infinite this will block forever.)
    <TKey> Map<TKey,​T>
    toMap​(Function<T,​TKey> keyFunc)
    Constructs a map from the elements of this Queriable where each element is assigned a key
    <TKey,​ TValue>
    Map<TKey,​TValue>
    toMap​(Function<T,​TKey> keyFunc, Function<T,​TValue> valueFunc)
    COnstructs a map from the elements of this Queriable
    Return an object which allows to transform this Iterable to a primitive-type array
    Return a list which contains all elements of this enumeration but no duplicates Returns a set which contains the elements which are also returned by distinct()
    union​(Iterable<T> toUnite)
    Return an enumeration which contains all elements of the current enumeration and all elements of the enumeration given as argument without duplicates (Equality is checked using the equals(...) method)
    union​(Iterable<T> toUnite, Equivalence<T> equalityComparer)
    Return an enumeration which contains all elements of the current enumeration and all elements of the enumeration given as argument without duplicates (Equality is checked using the given equalityComparer)
    where​(Predicate<T> predicate)
    Return all elements from the enumeration for which the predicate holds true or return an empty list if no such elements exist

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • isEmpty

      boolean isEmpty()
      Return if the enumeration is empty
      Returns:
      True if the enumeration is empty
    • defaultIfEmpty

      Queriable<T> defaultIfEmpty(T defaultValue)
      Returns this enumeration itself if it contains any elements or if it is empty an enumeration only containing the given defaultElement
      Parameters:
      defaultValue - The element to return if the enumeration is empty
      Returns:
      this enumeration or an enumeration containing defaultValue if this is empty
    • elementAt

      T elementAt(int index) throws NoSuchElementException
      Return the element at the given position or throw NoSuchElementException if no element at this index exits (i.e. the enumeration contains less than (index+1) elements)
      Parameters:
      index - Element index
      Returns:
      the element at the given index
      Throws:
      NoSuchElementException
    • elementAtOrDefault

      T elementAtOrDefault(int index)
      Return the element at the given position or return null if no element at this index exits (i.e. the enumeration contains less than (index+1) elements)
      Parameters:
      index - Element index
      Returns:
      the element at the given index or null if none exists
    • elementAtOrDefault

      T elementAtOrDefault(int index, T defaultValue)
      Return the element at the given position or return the given default value if no element at this index exits (i.e. the enumeration contains less than (index+1) elements)
      Parameters:
      index - Index of the elemt to return
      defaultValue - The value to return when no element at the given index exists
      Returns:
      The element at the index or defaultValue
    • sequenceEquals

      boolean sequenceEquals(Iterable<T> iterable)
      Checks whether this enumeration and the given iterable contain the same elements and the same position and have the same length (Equality is checked using Object.equals())
      Parameters:
      iterable - The iterable to compare with
      Returns:
      whether this and the given Iterable are considered equal
    • sequenceEquals

      boolean sequenceEquals(Iterable<T> iterable, Equivalence<T> equalityComparer)
      Checks whether this enumeration and the given iterable contain the same elements and the same position and have the same length (Equality is checked using the given custom Equivalence comparer)
      Parameters:
      iterable - The iterable to compare with
      equalityComparer - The comparison function to use
      Returns:
      whether this and the given Iterable are considered equal
    • all

      boolean all(Predicate<T> predicate)
      Return if all elements in the enumeration fulfill the given predicate
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      whether all elements satisfy the given predicate
    • exists

      boolean exists(Predicate<T> predicate)
      Test if at least one element of the enumeration fulfills the condition
      Parameters:
      predicate - Condition
      Returns:
      whether at least one element satisfies the given predicate
    • contains

      boolean contains(T element)
      Returns if this enumeration contains the given element (Equality is checked using Object.equals())
      Parameters:
      element - The element to check for
      Returns:
      whether the given element is contained in this sequence
    • contains

      boolean contains(T element, Equivalence<T> equalityComparer)
      Returns if this enumeration contains the given element (Equality is checked using the given Equivalence function)
      Parameters:
      element - The element to check for
      equalityComparer - The function to decide equality
      Returns:
      whether the given element is contained in this sequence
    • first

      T first() throws NoSuchElementException
      Return the first element of the enumeration or throw NoSuchElementException if the enumeration is empty
      Returns:
      The first element
      Throws:
      NoSuchElementException - Thrown if there is no element present
    • firstOrDefault

      T firstOrDefault()
      Return the first element of the enumeration or null if the enumeration is empty
      Returns:
      The first element or null
    • firstOrDefault

      T firstOrDefault(T defaultValue)
      Return the first element of the enumeration or the passed defaultValue if the enumeration is empty
      Parameters:
      defaultValue - The deafult value to use
      Returns:
      The first element or the given default value
    • first

      T first(Predicate<T> predicate) throws NoSuchElementException
      Return the first element of the enumeration for which the predicate is true or throw NoSuchElementException if no corresponding element exists
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      The first element which satisfies the predicate
      Throws:
      NoSuchElementException - Thrown if there is no element present which satisfies the predicate
    • firstOrDefault

      T firstOrDefault(Predicate<T> predicate)
      Return the first element in the enumeration for which the predicate is true or null if no corresponding element exists
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      The first element which satisfies the predicate or null
    • firstOrDefault

      T firstOrDefault(Predicate<T> predicate, T defaultValue)
      Return the first element in the enumeration for which the predicate is true or the given default value if no corresponding element exists
      Parameters:
      predicate - The predicate to evaluate
      defaultValue - The deafult value to use
      Returns:
      The first element which satisfies the predicate or defaultValue
    • last

      T last() throws NoSuchElementException
      Return the last element of the enumeration or throw NoSuchElementException if the enumeration is empty
      Returns:
      the last element of this sequence
      Throws:
      NoSuchElementException - Thrown if there is no element present which satisfies the predicate
    • lastOrDefault

      T lastOrDefault()
      Return the last element of the enumeration or null if the list is empty
      Returns:
      the last element of this sequence or null
    • last

      T last(Predicate<T> predicate) throws NoSuchElementException
      Return the last element of the enumeration for which the predicate is true or throw NoSuchElementException if no corresponding element exists
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      The last element which satisfies the predicate or defaultValue
      Throws:
      NoSuchElementException - Thrown if there is no element present which satisfies the predicate
    • lastOrDefault

      T lastOrDefault(Predicate<T> predicate)
      Return the last element in the enumeration for which the predicate is true or null if no corresponding element exists This is basically the same as .where(predicate).lastOrDefault()
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      The last element which satisfies the predicate or null
    • lastOrDefault

      T lastOrDefault(Predicate<T> predicate, T defaultValue)
      Return the last element in the enumeration for which the predicate is true or the given default value if no corresponding element exists This is basically the same as .where(predicate).lastOrDefault()
      Parameters:
      predicate - The predicate to evaluate
      defaultValue - The deafult value to use
      Returns:
      The last element which satisfies the predicate or defaultValue
    • single

      T single() throws NoSuchElementException
      If the iterable contains only one element return this element. Otherwise throw NoSuchElementException (i.e. if list is empty or contains more than 1 element)
      Returns:
      the only element in this sequence
      Throws:
      NoSuchElementException - Thrown if there is not exactly one element present
    • single

      T single(Predicate<T> predicate) throws NoSuchElementException
      If the iterable contains only one element which satisfies the condition return this element. Otherwise throw NoSuchElementException (i.e. if no or multiple elements satisfies the condition)
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      the only element in this sequence which fulfills the predicate
      Throws:
      NoSuchElementException - Thrown if there is not exactly one element which satisfies the predicate
    • singleOrDefault

      T singleOrDefault()
      If the iterable contains only one element return this element. Otherwise return null (i.e. if list is empty or contains more than 1 element)
      Returns:
      the only element in this sequence or null
    • singleOrDefault

      T singleOrDefault(Predicate<T> predicate)
      If the iterable contains only one element which satisfies the condition return this element. Otherwise return null (i.e. if no or multiple elements satisfies the condition)
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      the only element in this sequence which fulfills the predicate or null
    • count

      int count()
      Return the amount of elements in the enumeration if it is finite
      Returns:
      Count of elements in this sequence
    • count

      int count(Predicate<T> predicate)
      Return the amount of elements in the (finite) enumeration which satisfy the given predicate This is basically the same as .where(predicate).count()
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      Count of elements in this sequence
    • max

      T max()
      Returns the maximum element of the enumeration (Elements have to implement Comparable)
      Returns:
      the maximum element
      Throws:
      IllegalStateException - if there are no elements
    • max

      Number max(NumberFunc<T> valFunc)
      Return the maximum from the enumeration where the value for each item is calculated by the given function
      Parameters:
      valFunc - The function to calculate the value which shall be maximized for a single list item, the return value must always be of a single type (so for one list all return values for instance have to be either integers or doubles, but mixing is not possible)
      Returns:
      the maximum value or null if the list is empty
      Throws:
      IllegalStateException - if there are no elements
    • min

      T min()
      Returns the minimum element of the enumeration (Elements have to implement Comparable)
      Returns:
      the minimum element
      Throws:
      IllegalStateException - if there are no elements
    • min

      Number min(NumberFunc<T> valFunc)
      Return the minimum from the enumeration where the value for each item is calculated by the given function*
      Parameters:
      valFunc - The function to calculate the value which shall be minimized for a single list item, the return value must always be of a single type (so for one list all return values for instance have to be either integers or doubles, but mixing is not possible)
      Returns:
      the minimum value
      Throws:
      IllegalStateException - if there are no elements
    • average

      Number average()
      Return the average from the enumeration (Elements will be cast to java.lang.Number)
      Returns:
      the average value
      Throws:
      IllegalStateException - if there are no elements
    • average

      Number average(NumberFunc<T> valFunc)
      Return the average from the enumeration where the value for each item is calculated by the given function
      Parameters:
      valFunc - The function to calculate the values which shall be averagem, the return value must always be of a single type (so for one list all return values for instance have to be either integers or doubles, but mixing is not possible)
      Returns:
      the average value
      Throws:
      IllegalStateException - if there are no elements
    • sum

      Number sum()
      Return the sum from the enumeration where the value for each item (Elements will be cast to java.lang.Number)
      Returns:
      the sum or 0 (integer zero) if the list is empty
    • sum

      Number sum(NumberFunc<T> valFunc)
      Return the sum from the enumeration where the value for each item is calculated by the given function
      Parameters:
      valFunc - The function to calculate the values which shall be summed up for a single list item, the return value must always be of a single type (so for one list all return values for instance have to either integers or doubles, but mixing is not possible)
      Returns:
      the sum or 0 (integer zero) if the list is empty
    • where

      Queriable<T> where(Predicate<T> predicate)
      Return all elements from the enumeration for which the predicate holds true or return an empty list if no such elements exist
      Parameters:
      predicate - The predicate to evaluate
      Returns:
      A queriable sequence of the elements which satisfy the given predicate
    • select

      <TOut> Queriable<TOut> select(Selector<T,​TOut> selector)
      Transforms each element of the enumeration using a selector
      Type Parameters:
      TOut - The target type of the selection
      Parameters:
      selector - The transformation function
      Returns:
      A queriable sequence of the transformed elements
    • selectMany

      <TOut> Queriable<TOut> selectMany(Selector<T,​Iterable<TOut>> selector)
      Transform each element of the enumeration into another enumeration and combine all results to a single list
      Type Parameters:
      TOut - The target type of the selection
      Parameters:
      selector - The transformation function
      Returns:
      A queriable sequence of the transformed elements
    • cast

      <TOut> Queriable<TOut> cast(Class<TOut> targetType)
      Cast each element of the enumeration to the given type and return an enumeration of this type (This is an unchecked cast, so if any element in the enumeration cannot be cast to the given type an exception will be thrown)
      Type Parameters:
      TOut - The target type of the selection (equals targetType)
      Parameters:
      targetType - The type to cast to
      Returns:
      A queriable sequence of type-cast elements
    • ofType

      <TOut> Queriable<TOut> ofType(Class<TOut> targetType)
      Return the elements of the enumeration which are of the requested type or can be cast to it
      Type Parameters:
      TOut - The target type of the filtering (equals targetType)
      Parameters:
      targetType - The type to filter
      Returns:
      A queriable sequence of elements of the given type
    • concat

      Queriable<T> concat(Iterable<T> toConcat)
      Return an enumeration which contains all elements of the current enumeration and all elements of the enumeration given as argument
      Parameters:
      toConcat - Elements to concatenate
      Returns:
      A queriable sequence which contains the elements of this sequence and of the elements from toConcat
    • union

      Queriable<T> union(Iterable<T> toUnite)
      Return an enumeration which contains all elements of the current enumeration and all elements of the enumeration given as argument without duplicates (Equality is checked using the equals(...) method)
      Parameters:
      toUnite - Elements to unite with
      Returns:
      A queriable sequence which contains the union of this sequence and the given Iterable
    • union

      Queriable<T> union(Iterable<T> toUnite, Equivalence<T> equalityComparer)
      Return an enumeration which contains all elements of the current enumeration and all elements of the enumeration given as argument without duplicates (Equality is checked using the given equalityComparer)
      Parameters:
      toUnite - Elements to unite with
      equalityComparer - Comparer to determine if two elements are equal
      Returns:
      A queriable sequence which contains the union of this sequence and the given Iterable
    • intersect

      Queriable<T> intersect(Iterable<T> intersectWith)
      Returns an iterable which contains the elements of this enumeration which also exist in the given Iterable (Equality is checked using the equals(...) method)
      Parameters:
      intersectWith - Elements to intersect with
      Returns:
      A queriable sequence which contains the intersection of this sequence and the given Iterable
    • intersect

      Queriable<T> intersect(Iterable<T> intersectWith, Equivalence<T> equalityComparer)
      Returns an iterable which contains the elements of this enumeration which also exist in the given Iterable (Equality is checked using the given equalityComparer)
      Parameters:
      intersectWith - Elements to intersect with
      equalityComparer - Comparer to determine if two elements are equal
      Returns:
      A queriable sequence which contains the union of this sequence and the given Iterable
    • except

      Queriable<T> except(Iterable<T> elementsToSubtract)
      Returns an iterable which contains only the elements of this enumeration which do not exist in the given Iterable (Equality is checked using the equals(...) method)
      Parameters:
      elementsToSubtract - Elements to exclude
      Returns:
      A queriable sequence which contains only elements of this sequence which are not containedin the given Iterable
    • except

      Queriable<T> except(Iterable<T> elementsToSubtract, Equivalence<T> equalityComparer)
      Returns an iterable which contains only the elements of this enumeration which do not exist in the given Iterable (Equality is checked using the given equalityComparer)
      Parameters:
      elementsToSubtract - Elements to exclude
      equalityComparer - Comparer to determine if two elements are equal
      Returns:
      A queriable sequence which contains only elements of this sequence which are not containedin the given Iterable
    • distinct

      Queriable<T> distinct()
      Returns an enumeration where each item of the enumeration appears exactly once (Equality is checked using the equals(...) method)
      Returns:
      all elements of this sequence without duplicates
    • distinct

      Queriable<T> distinct(Equivalence<T> equalityComparer)
      Returns an enumeration where each item of the enumeration appears exactly once (Equality is checked using the given equalityComparer)
      Parameters:
      equalityComparer - Comparer to determine if two elements are equal
      Returns:
      all elements of this sequence without duplicates
    • take

      Queriable<T> take(int amount)
      Take the given amount of elements from the enumeration or take elements until the enumeration ends
      Parameters:
      amount - max. amount of elements to take
      Returns:
      The first 'amount' of elements of this sequence (or less if fewer elements are present)
    • takeWhile

      Queriable<T> takeWhile(Predicate<T> condition)
      Take elements from the enumeration as long as they satisfy the condition or until the enumeration ends
      Parameters:
      condition - Condition to take an element
      Returns:
      The taken elements
    • skip

      Queriable<T> skip(int amount)
      Skip the given amount of elements in the list and return a Queriable which starts at the (amount+1)th element or is empty if the enumeration did not contain more than amount elements
      Parameters:
      amount - Number of elements to skip
      Returns:
      The elements of this sequence after the first 'amount' elements
    • skipWhile

      Queriable<T> skipWhile(Predicate<T> condition)
      Return a queriable which starts at the first element of the enumeration which does not satisfy the condition, if no such element exists the returned Queriable is empty
      Parameters:
      condition - skip condition
      Returns:
      The elements after the skipped elements
    • group

      GroupedQueriable<T> group(GroupFunction<T> func)
      Groups the elements of the enumeration according to the given grouping function
      Parameters:
      func - Function to group elements by
      Returns:
      The grouped elements
    • groupSingle

      GroupedQueriable<T> groupSingle(SingleKeyGroupFunction<T> func)
      Groups the elements of the enumeration according to the given grouping function (Convenience function for grouping with only one group key element)
      Parameters:
      func - Function to group elements by
      Returns:
      The grouped elements
    • orderBy

      OrderedQueriable<T> orderBy(ItemFunc<T,​Comparable> func)
      Order the elements of this enumeration according to the values returned by the order function
      Parameters:
      func - Function to retrieve the value to compare from an element
      Returns:
      The ordered elements
    • orderBy

      <TComparable> OrderedQueriable<T> orderBy(ItemFunc<T,​TComparable> valueFunc, Comparator<TComparable> comparator)
      Order the elements of this enumeration according to the values returned by the value function function using the given comparator
      Type Parameters:
      TComparable - The type to compare with
      Parameters:
      valueFunc - Function to retrieve the value to compare from an element
      comparator - Comparator to compare values
      Returns:
      The ordered elements
    • orderByDescending

      OrderedQueriable<T> orderByDescending(ItemFunc<T,​Comparable> func)
      Order the elements of this enumeration according the values returned by the order function in descending order
      Parameters:
      func - Function to retrieve the value to compare from an element
      Returns:
      The ordered elements
    • orderByDescending

      <TComparable> OrderedQueriable<T> orderByDescending(ItemFunc<T,​TComparable> valueFunc, Comparator<TComparable> comparator)
      Order the elements of this enumeration according to the values returned by the value function function using the given comparator in descending order
      Type Parameters:
      TComparable - The type to compare with
      Parameters:
      valueFunc - Function to retrieve the value to compare from an element
      comparator - Comparator to compare values
      Returns:
      The ordered elements
    • reverse

      Queriable<T> reverse()
      Reverse the order of elements of this enumeration
      Returns:
      A reversed sequence
    • toList

      List<T> toList()
      Return a list which contains all elements of this enumeration (This will evaluate the whole enumeration, if it is infinite this will block forever.)
      Returns:
      List of the elements ot this sequence
    • toSet

      Set<T> toSet()
      Return a list which contains all elements of this enumeration but no duplicates Returns a set which contains the elements which are also returned by distinct()
      Returns:
      Set of the elements ot this sequence
    • toMap

      <TKey,​ TValue> Map<TKey,​TValue> toMap(Function<T,​TKey> keyFunc, Function<T,​TValue> valueFunc)
      COnstructs a map from the elements of this Queriable
      Type Parameters:
      TKey - The type of the map keys
      TValue - The type of the map values
      Parameters:
      keyFunc - The function to retrieve the map key from an element
      valueFunc - The function to retrieve the map value from an element
      Returns:
      The map
    • toMap

      <TKey> Map<TKey,​T> toMap(Function<T,​TKey> keyFunc)
      Constructs a map from the elements of this Queriable where each element is assigned a key
      Type Parameters:
      TKey - The type of the map keys
      Parameters:
      keyFunc - The function to retrieve the map key from an element*
      Returns:
      The map
    • toArray

      T[] toArray(Class<T> classType)
      Return an array which contains all elements of this enumeration (This will evaluate the whole enumeration, if it is infinite this will block forever.)
      Parameters:
      classType - The class type of T
      Returns:
      An array of the elements ot this sequence
    • toPrimitiveArray

      PrimitiveArrayTransformer<T> toPrimitiveArray()
      Return an object which allows to transform this Iterable to a primitive-type array
      Returns:
      An instance of PrimitiveArrayTransformer