Class QueryableDefaults


  • public abstract class QueryableDefaults
    extends java.lang.Object
    Default implementations for methods in the Queryable interface.
    • Constructor Detail

      • QueryableDefaults

        public QueryableDefaults()
    • Method Detail

      • aggregate

        public static <T,​TAccumulate> TAccumulate aggregate​(Queryable<T> queryable,
                                                                  TAccumulate seed,
                                                                  FunctionExpression<Function2<TAccumulate,​T,​TAccumulate>> func)
        Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
      • aggregate

        public static <T,​TAccumulate,​TResult> TResult aggregate​(Queryable<T> queryable,
                                                                            TAccumulate seed,
                                                                            FunctionExpression<Function2<TAccumulate,​T,​TAccumulate>> func,
                                                                            FunctionExpression<Function1<TAccumulate,​TResult>> selector)
        Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
      • any

        public static <T> void any​(Queryable<T> queryable)
        Determines whether a sequence contains any elements.
      • asQueryable

        public static <T> Queryable<T> asQueryable​(Queryable<T> queryable)
        Converts a generic Enumerable<T> to a generic IQueryable<T>.
      • averageBigDecimal

        public static <T> java.math.BigDecimal averageBigDecimal​(Queryable<T> queryable,
                                                                 FunctionExpression<BigDecimalFunction1<T>> selector)
        Computes the average of a sequence of Decimal values that is obtained by invoking a projection function on each element of the input sequence.
      • averageNullableBigDecimal

        public static <T> java.math.BigDecimal averageNullableBigDecimal​(Queryable<T> queryable,
                                                                         FunctionExpression<NullableBigDecimalFunction1<T>> selector)
        Computes the average of a sequence of nullable Decimal values that is obtained by invoking a projection function on each element of the input sequence.
      • averageDouble

        public static <T> double averageDouble​(Queryable<T> queryable,
                                               FunctionExpression<DoubleFunction1<T>> selector)
        Computes the average of a sequence of Double values that is obtained by invoking a projection function on each element of the input sequence.
      • averageNullableDouble

        public static <T> java.lang.Double averageNullableDouble​(Queryable<T> queryable,
                                                                 FunctionExpression<NullableDoubleFunction1<T>> selector)
        Computes the average of a sequence of nullable Double values that is obtained by invoking a projection function on each element of the input sequence.
      • averageInteger

        public static <T> int averageInteger​(Queryable<T> queryable,
                                             FunctionExpression<IntegerFunction1<T>> selector)
        Computes the average of a sequence of int values that is obtained by invoking a projection function on each element of the input sequence.
      • averageNullableInteger

        public static <T> java.lang.Integer averageNullableInteger​(Queryable<T> queryable,
                                                                   FunctionExpression<NullableIntegerFunction1<T>> selector)
        Computes the average of a sequence of nullable int values that is obtained by invoking a projection function on each element of the input sequence.
      • averageFloat

        public static <T> float averageFloat​(Queryable<T> queryable,
                                             FunctionExpression<FloatFunction1<T>> selector)
        Computes the average of a sequence of Float values that is obtained by invoking a projection function on each element of the input sequence.
      • averageNullableFloat

        public static <T> java.lang.Float averageNullableFloat​(Queryable<T> queryable,
                                                               FunctionExpression<NullableFloatFunction1<T>> selector)
        Computes the average of a sequence of nullable Float values that is obtained by invoking a projection function on each element of the input sequence.
      • averageLong

        public static <T> long averageLong​(Queryable<T> queryable,
                                           FunctionExpression<LongFunction1<T>> selector)
        Computes the average of a sequence of long values that is obtained by invoking a projection function on each element of the input sequence.
      • averageNullableLong

        public static <T> java.lang.Long averageNullableLong​(Queryable<T> queryable,
                                                             FunctionExpression<NullableLongFunction1<T>> selector)
        Computes the average of a sequence of nullable long values that is obtained by invoking a projection function on each element of the input sequence.
      • cast

        public static <T,​T2> Queryable<T2> cast​(Queryable<T> source,
                                                      java.lang.Class<T2> clazz)

        Analogous to LINQ's Enumerable.Cast extension method.

        Type Parameters:
        T2 - Target type
        Parameters:
        clazz - Target type
        Returns:
        Collection of T2
      • contains

        public static <T> boolean contains​(Queryable<T> queryable,
                                           T element)
        Determines whether a sequence contains a specified element by using the default equality comparer.
      • contains

        public static <T> boolean contains​(Queryable<T> queryable,
                                           T element,
                                           EqualityComparer comparer)
        Determines whether a sequence contains a specified element by using a specified EqualityComparer<T>.
      • count

        public static <T> int count​(Queryable<T> queryable)
        Returns the number of elements in a sequence.
      • count

        public static <T> int count​(Queryable<T> queryable,
                                    FunctionExpression<Predicate1<T>> func)
        Returns the number of elements in the specified sequence that satisfies a condition.
      • defaultIfEmpty

        public static <T> Queryable<T> defaultIfEmpty​(Queryable<T> queryable)
        Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the sequence is empty.
      • defaultIfEmpty

        public static <T> T defaultIfEmpty​(Queryable<T> queryable,
                                           T value)
        Returns the elements of the specified sequence or the specified value in a singleton collection if the sequence is empty.
      • distinct

        public static <T> Queryable<T> distinct​(Queryable<T> queryable)
        Returns distinct elements from a sequence by using the default equality comparer to compare values.
      • distinct

        public static <T> Queryable<T> distinct​(Queryable<T> queryable,
                                                EqualityComparer comparer)
        Returns distinct elements from a sequence by using a specified EqualityComparer<T> to compare values.
      • elementAt

        public static <T> T elementAt​(Queryable<T> queryable,
                                      int index)
        Returns the element at a specified index in a sequence.
      • elementAtOrDefault

        public static <T> T elementAtOrDefault​(Queryable<T> queryable,
                                               int index)
        Returns the element at a specified index in a sequence or a default value if the index is out of range.
      • except

        public static <T> Queryable<T> except​(Queryable<T> queryable,
                                              Enumerable<T> enumerable)
        Produces the set difference of two sequences by using the default equality comparer to compare values. (Defined by Queryable.)
      • except

        public static <T> Queryable<T> except​(Queryable<T> queryable,
                                              Enumerable<T> enumerable,
                                              EqualityComparer<T> comparer)
        Produces the set difference of two sequences by using the specified EqualityComparer<T> to compare values.
      • first

        public static <T> T first​(Queryable<T> queryable)
        Returns the first element of a sequence. (Defined by Queryable.)
      • first

        public static <T> T first​(Queryable<T> queryable,
                                  FunctionExpression<Predicate1<T>> predicate)
        Returns the first element of a sequence that satisfies a specified condition.
      • firstOrDefault

        public static <T> T firstOrDefault​(Queryable<T> queryable)
        Returns the first element of a sequence, or a default value if the sequence contains no elements.
      • firstOrDefault

        public static <T> T firstOrDefault​(Queryable<T> queryable,
                                           FunctionExpression<Predicate1<T>> predicate)
        Returns the first element of a sequence that satisfies a specified condition or a default value if no such element is found.
      • intersect

        public static <T> Queryable<T> intersect​(Queryable<T> queryable,
                                                 Enumerable<T> enumerable)
        Produces the set intersection of two sequences by using the default equality comparer to compare values. (Defined by Queryable.)
      • intersect

        public static <T> Queryable<T> intersect​(Queryable<T> queryable,
                                                 Enumerable<T> enumerable,
                                                 EqualityComparer<T> comparer)
        Produces the set intersection of two sequences by using the specified EqualityComparer<T> to compare values.
      • last

        public static <T> T last​(Queryable<T> queryable)
        Returns the last element in a sequence. (Defined by Queryable.)
      • last

        public static <T> T last​(Queryable<T> queryable,
                                 FunctionExpression<Predicate1<T>> predicate)
        Returns the last element of a sequence that satisfies a specified condition.
      • lastOrDefault

        public static <T> T lastOrDefault​(Queryable<T> queryable)
        Returns the last element in a sequence, or a default value if the sequence contains no elements.
      • lastOrDefault

        public static <T> T lastOrDefault​(Queryable<T> queryable,
                                          FunctionExpression<Predicate1<T>> predicate)
        Returns the last element of a sequence that satisfies a condition or a default value if no such element is found.
      • longCount

        public static <T> long longCount​(Queryable<T> xable)
        Returns an long that represents the total number of elements in a sequence.
      • longCount

        public static <T> long longCount​(Queryable<T> queryable,
                                         FunctionExpression<Predicate1<T>> predicate)
        Returns an long that represents the number of elements in a sequence that satisfy a condition.
      • max

        public static <T> T max​(Queryable<T> queryable)
        Returns the maximum value in a generic IQueryable<T>.
      • max

        public static <T,​TResult> TResult max​(Queryable<T> queryable,
                                                    FunctionExpression<Function1<T,​TResult>> selector)
        Invokes a projection function on each element of a generic IQueryable<T> and returns the maximum resulting value.
      • min

        public static <T> T min​(Queryable<T> queryable)
        Returns the minimum value in a generic IQueryable<T>.
      • min

        public static <T,​TResult> TResult min​(Queryable<T> queryable,
                                                    FunctionExpression<Function1<T,​TResult>> selector)
        Invokes a projection function on each element of a generic IQueryable<T> and returns the minimum resulting value.
      • ofType

        public static <TResult> Queryable<TResult> ofType​(Queryable<?> queryable,
                                                          java.lang.Class<TResult> clazz)
        Filters the elements of an IQueryable based on a specified type.

        This method generates a MethodCallExpression that represents calling ofType itself as a constructed generic method. It then passes the MethodCallExpression to the createQuery method of the QueryProvider represented by the Provider property of the source parameter.

        The query behavior that occurs as a result of executing an expression tree that represents calling OfType depends on the implementation of the type of the source parameter. The expected behavior is that it filters out any elements in source that are not of type TResult.

        NOTE: clazz parameter not present in C# LINQ; necessary because of Java type erasure.

      • orderBy

        public static <T,​TKey> OrderedQueryable<T> orderBy​(Queryable<T> source,
                                                                 FunctionExpression<Function1<T,​TKey>> keySelector,
                                                                 java.util.Comparator<TKey> comparator)
        Sorts the elements of a sequence in ascending order by using a specified comparer.
      • orderByDescending

        public static <T,​TKey extends java.lang.Comparable> OrderedQueryable<T> orderByDescending​(Queryable<T> source,
                                                                                                        FunctionExpression<Function1<T,​TKey>> keySelector)
        Sorts the elements of a sequence in descending order according to a key.
      • orderByDescending

        public static <T,​TKey> OrderedQueryable<T> orderByDescending​(Queryable<T> source,
                                                                           FunctionExpression<Function1<T,​TKey>> keySelector,
                                                                           java.util.Comparator<TKey> comparator)
        Sorts the elements of a sequence in descending order by using a specified comparer.
      • reverse

        public static <T> Queryable<T> reverse​(Queryable<T> source)
        Inverts the order of the elements in a sequence.
      • functionResultType

        private static <P0,​R> java.lang.reflect.Type functionResultType​(FunctionExpression<Function1<P0,​R>> selector)
      • selectMany

        public static <T,​TResult> Queryable<TResult> selectMany​(Queryable<T> source,
                                                                      FunctionExpression<Function1<T,​Enumerable<TResult>>> selector)
        Projects each element of a sequence to an Enumerable<T> and combines the resulting sequences into one sequence.
      • selectMany

        public static <T,​TCollection,​TResult> Queryable<TResult> selectMany​(Queryable<T> source,
                                                                                        FunctionExpression<Function2<T,​java.lang.Integer,​Enumerable<TCollection>>> collectionSelector,
                                                                                        FunctionExpression<Function2<T,​TCollection,​TResult>> resultSelector)
        Projects each element of a sequence to an Enumerable<T> that incorporates the index of the source element that produced it. A result selector function is invoked on each element of each intermediate sequence, and the resulting values are combined into a single, one-dimensional sequence and returned.
      • sequenceEqual

        public static <T> boolean sequenceEqual​(Queryable<T> queryable,
                                                Enumerable<T> enumerable)
        Determines whether two sequences are equal by using the default equality comparer to compare elements.
      • sequenceEqual

        public static <T> boolean sequenceEqual​(Queryable<T> queryable,
                                                Enumerable<T> enumerable,
                                                EqualityComparer<T> comparer)
        Determines whether two sequences are equal by using a specified EqualityComparer<T> to compare elements.
      • single

        public static <T> T single​(Queryable<T> source)
        Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence.
      • single

        public static <T> T single​(Queryable<T> source,
                                   FunctionExpression<Predicate1<T>> predicate)
        Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists.
      • singleOrDefault

        public static <T> T singleOrDefault​(Queryable<T> source)
        Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence.
      • singleOrDefault

        public static <T> T singleOrDefault​(Queryable<T> source,
                                            FunctionExpression<Predicate1<T>> predicate)
        Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition.
      • skip

        public static <T> Queryable<T> skip​(Queryable<T> source,
                                            int count)
        Bypasses a specified number of elements in a sequence and then returns the remaining elements.
      • skipWhile

        public static <T> Queryable<T> skipWhile​(Queryable<T> source,
                                                 FunctionExpression<Predicate1<T>> predicate)
        Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.
      • skipWhileN

        public static <T> Queryable<T> skipWhileN​(Queryable<T> source,
                                                  FunctionExpression<Predicate2<T,​java.lang.Integer>> predicate)
        Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements. The element's index is used in the logic of the predicate function.
      • sumBigDecimal

        public static <T> java.math.BigDecimal sumBigDecimal​(Queryable<T> sources,
                                                             FunctionExpression<BigDecimalFunction1<T>> selector)
        Computes the sum of the sequence of Decimal values that is obtained by invoking a projection function on each element of the input sequence.
      • sumNullableBigDecimal

        public static <T> java.math.BigDecimal sumNullableBigDecimal​(Queryable<T> source,
                                                                     FunctionExpression<NullableBigDecimalFunction1<T>> selector)
        Computes the sum of the sequence of nullable Decimal values that is obtained by invoking a projection function on each element of the input sequence.
      • sumDouble

        public static <T> double sumDouble​(Queryable<T> source,
                                           FunctionExpression<DoubleFunction1<T>> selector)
        Computes the sum of the sequence of Double values that is obtained by invoking a projection function on each element of the input sequence.
      • sumNullableDouble

        public static <T> java.lang.Double sumNullableDouble​(Queryable<T> source,
                                                             FunctionExpression<NullableDoubleFunction1<T>> selector)
        Computes the sum of the sequence of nullable Double values that is obtained by invoking a projection function on each element of the input sequence.
      • sumInteger

        public static <T> int sumInteger​(Queryable<T> source,
                                         FunctionExpression<IntegerFunction1<T>> selector)
        Computes the sum of the sequence of int values that is obtained by invoking a projection function on each element of the input sequence.
      • sumNullableInteger

        public static <T> java.lang.Integer sumNullableInteger​(Queryable<T> source,
                                                               FunctionExpression<NullableIntegerFunction1<T>> selector)
        Computes the sum of the sequence of nullable int values that is obtained by invoking a projection function on each element of the input sequence.
      • sumLong

        public static <T> long sumLong​(Queryable<T> source,
                                       FunctionExpression<LongFunction1<T>> selector)
        Computes the sum of the sequence of long values that is obtained by invoking a projection function on each element of the input sequence.
      • sumNullableLong

        public static <T> java.lang.Long sumNullableLong​(Queryable<T> source,
                                                         FunctionExpression<NullableLongFunction1<T>> selector)
        Computes the sum of the sequence of nullable long values that is obtained by invoking a projection function on each element of the input sequence.
      • sumFloat

        public static <T> float sumFloat​(Queryable<T> source,
                                         FunctionExpression<FloatFunction1<T>> selector)
        Computes the sum of the sequence of Float values that is obtained by invoking a projection function on each element of the input sequence.
      • sumNullableFloat

        public static <T> java.lang.Float sumNullableFloat​(Queryable<T> source,
                                                           FunctionExpression<NullableFloatFunction1<T>> selector)
        Computes the sum of the sequence of nullable Float values that is obtained by invoking a projection function on each element of the input sequence.
      • take

        public static <T> Queryable<T> take​(Queryable<T> source,
                                            int count)
        Returns a specified number of contiguous elements from the start of a sequence.
      • takeWhileN

        public static <T> Queryable<T> takeWhileN​(Queryable<T> source,
                                                  FunctionExpression<Predicate2<T,​java.lang.Integer>> predicate)
        Returns elements from a sequence as long as a specified condition is true. The element's index is used in the logic of the predicate function.
      • thenBy

        public static <T,​TKey> OrderedQueryable<T> thenBy​(OrderedQueryable<T> source,
                                                                FunctionExpression<Function1<T,​TKey>> keySelector,
                                                                java.util.Comparator<TKey> comparator)
        Performs a subsequent ordering of the elements in a sequence in ascending order according to a key, using a specified comparator.
      • thenByDescending

        public static <T,​TKey extends java.lang.Comparable<TKey>> OrderedQueryable<T> thenByDescending​(OrderedQueryable<T> source,
                                                                                                             FunctionExpression<Function1<T,​TKey>> keySelector)
        Performs a subsequent ordering of the elements in a sequence in descending order according to a key.
      • thenByDescending

        public static <T,​TKey> OrderedQueryable<T> thenByDescending​(OrderedQueryable<T> source,
                                                                          FunctionExpression<Function1<T,​TKey>> keySelector,
                                                                          java.util.Comparator<TKey> comparator)
        Performs a subsequent ordering of the elements in a sequence in dscending order according to a key, using a specified comparator.
      • union

        public static <T> Queryable<T> union​(Queryable<T> source0,
                                             Enumerable<T> source1)
        Produces the set union of two sequences by using the default equality comparer.
      • whereN

        public static <T> Queryable<T> whereN​(Queryable<T> source,
                                              FunctionExpression<Predicate2<T,​java.lang.Integer>> predicate)
        Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.