Package: org.apache.groovy.ginq.provider.collection.runtime

## [Java] Interface Queryable<T>

-     public interface Queryable<T>

  Represents the queryable objects, e.g. Java collections

  Type Parameters:
    `T` - the type of Queryable element
  Since:
    4.0.0

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `class` | `Queryable.Order` | Represents an order rule

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `<U>` | `public U` | `agg(Function<? super Queryable<? extends T>, ? extends U> mapper)` The most powerful aggregate function in GINQ, it will receive the grouped result(Queryable instance) and apply any processing
    `` | `public BigDecimal` | `avg(Function<? super T, ? extends Number> mapper)` Aggregate function `avg`, similar to SQL's `avg`
    `` | `public Long` | `count()` Aggregate function `count`, similar to SQL's `count`
    `<U>` | `public Long` | `count(Function<? super T, ? extends U> mapper)` Aggregate function `count`, similar to SQL's `count` Note: if the chosen field is `null`, the field will not be counted
    `<U>` | `public Queryable<Tuple2<T, U>>` | `crossJoin(Queryable<? extends U> queryable)` Cross join another Queryable instance, similar to SQL's `cross join`
    `` | `public Queryable<T>` | `distinct()` Eliminate duplicated records, similar to SQL's `distinct`
    `<T>` | `public static Queryable<T>` | `emptyQueryable()` Returns the empty Queryable instance
    `` | `public boolean` | `exists()` Check if the result is empty, similar to SQL's `exists`
    `<T>` | `public static Queryable<T>` | `from(Iterable<T> iterable)` Factory method to create Queryable instance
    `<T>` | `public static Queryable<T>` | `from(T[] array)` Factory method to create Queryable instance
    `<T>` | `public static Queryable<T>` | `from(Stream<T> sourceStream)` Factory method to create Queryable instance
    `<T>` | `public static Queryable<T>` | `from(Queryable<T> queryable)` Returns the original Queryable instance directly
    `<U>` | `public Queryable<Tuple2<T, U>>` | `fullHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)` Full hash join another Queryable instance, similar to SQL's `full join`
    `<U>` | `public Queryable<Tuple2<T, U>>` | `fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)` Full join another Queryable instance, similar to SQL's `full join`
    `` | `public Queryable<Tuple2<?, Queryable<T>>>` | `groupBy(Function<? super T, ?> classifier, Predicate<? super Tuple2<?, Queryable<? extends T>>> having)` Group by Queryable instance, similar to SQL's `group by`
    `` | `public Queryable<Tuple2<?, Queryable<T>>>` | `groupBy(Function<? super T, ?> classifier)` Group by Queryable instance without `having` clause, similar to SQL's `group by`
    `<K>` | `public Queryable<GroupResult<K, T>>` | `groupByInto(Function<? super T, ? extends K> classifier, Predicate<? super GroupResult<K, T>> having)` Group by Queryable instance, returning GroupResult instances for use with the `groupby...into` syntax.
    `<K>` | `public Queryable<GroupResult<K, T>>` | `groupByInto(Function<? super T, ? extends K> classifier)` Group by Queryable instance without `having` clause, returning GroupResult instances.
    `<U>` | `public Queryable<Tuple2<T, U>>` | `innerHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)` Inner hash join another Queryable instance, similar to SQL's `inner hash join`.
    `<U>` | `public Queryable<Tuple2<T, U>>` | `innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)` Inner join another Queryable instance, similar to SQL's `inner join`
    `` | `public Queryable<T>` | `intersect(Queryable<? extends T> queryable)` Intersect another Queryable instance, similar to SQL's `intersect`
    `<U>` | `public Queryable<Tuple2<T, U>>` | `leftHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)` Left hash join another Queryable instance, similar to SQL's `left hash join`
    `<U>` | `public Queryable<Tuple2<T, U>>` | `leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)` Left join another Queryable instance, similar to SQL's `left join`
    `` | `public Queryable<T>` | `limit(long offset, long size)` Paginate Queryable instance, similar to MySQL's `limit`
    `` | `public Queryable<T>` | `limit(long size)` Paginate Queryable instance, similar to MySQL's `limit`
    `<U>` | `public List<U>` | `list(Function<? super T, ? extends U> mapper)` Aggregate function `list`.
    `<U extends Comparable<? super U>>` | `public U` | `max(Function<? super T, ? extends U> mapper)` Aggregate function `max`, similar to SQL's `max`
    `` | `public BigDecimal` | `median(Function<? super T, ? extends Number> mapper)` Aggregate function `median`, similar to SQL's `median`
    `<U extends Comparable<? super U>>` | `public U` | `min(Function<? super T, ? extends U> mapper)` Aggregate function `min`, similar to SQL's `min`
    `` | `public Queryable<T>` | `minus(Queryable<? extends T> queryable)` Minus another Queryable instance, similar to SQL's `minus`
    `<U extends Comparable<? super U>>` | `public Queryable<T>` | `orderBy(Order<? super T, ? extends U> orders)` Sort Queryable instance, similar to SQL's `order by`
    `<U extends Comparable<? super U>>` | `public Queryable<T>` | `orderBy(List<? extends Order<? super T, ? extends U>> orders)` Sort Queryable instance, similar to SQL's `order by`
    `<U extends Comparable<? super U>>` | `public Window<T>` | `over(Tuple2<T, Long> currentRecord, WindowDefinition<T, U> windowDefinition)` Open window for current record
    `<U>` | `public Queryable<Tuple2<T, U>>` | `rightHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)` Right hash join another Queryable instance, similar to SQL's `right join`
    `<U>` | `public Queryable<Tuple2<T, U>>` | `rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)` Right join another Queryable instance, similar to SQL's `right join`
    `<U>` | `public Queryable<U>` | `select(BiFunction<? super T, ? super Queryable<? extends T>, ? extends U> mapper)` Project Queryable instance, similar to SQL's `select`
    `` | `public long` | `size()` Returns the count of elements of the Queryable instance
    `` | `public BigDecimal` | `stdev(Function<? super T, ? extends Number> mapper)` Aggregate function `stdev`, similar to SQL's `stdev`
    `` | `public BigDecimal` | `stdevp(Function<? super T, ? extends Number> mapper)` Aggregate function `stdevp`, similar to SQL's `stdevp`
    `` | `public Stream<T>` | `stream()` Create Stream<T> object for the Queryable instance
    `` | `public BigDecimal` | `sum(Function<? super T, ? extends Number> mapper)` Aggregate function `sum`, similar to SQL's `sum`
    `` | `public List<T>` | `toList()` Convert the Queryable instance to List<T> instance
    `` | `public Queryable<T>` | `union(Queryable<? extends T> queryable)` Union another Queryable instance, similar to SQL's `union`
    `` | `public Queryable<T>` | `unionAll(Queryable<? extends T> queryable)` Union all another Queryable instance, similar to SQL's `union all`
    `` | `public BigDecimal` | `var(Function<? super T, ? extends Number> mapper)` Aggregate function `var`, similar to SQL's `var`
    `` | `public BigDecimal` | `varp(Function<? super T, ? extends Number> mapper)` Aggregate function `varp`, similar to SQL's `varp`
    `` | `public Queryable<T>` | `where(Predicate<? super T> filter)` Filter Queryable instance via some condition, similar to SQL's `where`

- - ### Method Detail

    - #### <U> public U agg(Function<? super Queryable<? extends T>, ? extends U> mapper)

      The most powerful aggregate function in GINQ, it will receive the grouped result(Queryable instance) and apply any processing

      Parameters:
        `mapper` - map the grouped result(Queryable instance) to aggregate result
      Type Parameters:
        `U` - the type aggregate result
      Returns:
        aggregate result
      Since:
        4.0.0

    - #### public BigDecimal avg(Function<? super T, ? extends Number> mapper)

      Aggregate function `avg`, similar to SQL's `avg`

      Parameters:
        `mapper` - choose the field to calculate the average
      Returns:
        avg result
      Since:
        4.0.0

    - #### public Long count()

      Aggregate function `count`, similar to SQL's `count`

      Returns:
        count result
      Since:
        4.0.0

    - #### <U> public Long count(Function<? super T, ? extends U> mapper)

      Aggregate function `count`, similar to SQL's `count` Note: if the chosen field is `null`, the field will not be counted

      Parameters:
        `mapper` - choose the field to count
      Returns:
        count result
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> crossJoin(Queryable<? extends U> queryable)

      Cross join another Queryable instance, similar to SQL's `cross join`

      Parameters:
        `queryable` - another Queryable instance
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### public Queryable<T> distinct()

      Eliminate duplicated records, similar to SQL's `distinct`

      Returns:
        the distinct result
      Since:
        4.0.0

    - #### <T> public static Queryable<T> emptyQueryable()

      Returns the empty Queryable instance

      Type Parameters:
        `T` - the type of element
      Returns:
        the empty Queryable instance
      Since:
        4.0.0

    - #### public boolean exists()

      Check if the result is empty, similar to SQL's `exists`

      Returns:
        the result of checking, `true` if result is not empty, otherwise `false`

    - #### <T> public static Queryable<T> from(Iterable<T> iterable)

      Factory method to create Queryable instance

      Parameters:
        `iterable` - iterable object, e.g. List
      Type Parameters:
        `T` - the type of element
      Returns:
        the Queryable instance
      Since:
        4.0.0

    - #### <T> public static Queryable<T> from(T[] array)

      Factory method to create Queryable instance

      Parameters:
        `array` - array object
      Type Parameters:
        `T` - the type of element
      Returns:
        the Queryable instance
      Since:
        4.0.0

    - #### <T> public static Queryable<T> from(Stream<T> sourceStream)

      Factory method to create Queryable instance

      Parameters:
        `sourceStream` - stream object
      Type Parameters:
        `T` - the type of element
      Returns:
        the Queryable instance
      Since:
        4.0.0

    - #### <T> public static Queryable<T> from(Queryable<T> queryable)

      Returns the original Queryable instance directly

      Parameters:
        `queryable` - queryable object
      Type Parameters:
        `T` - the type of element
      Returns:
        the Queryable instance
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> fullHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)

      Full hash join another Queryable instance, similar to SQL's `full join`

      Parameters:
        `queryable` - another Queryable instance
        `fieldsExtractor1` - extract fields of one data source
        `fieldsExtractor2` - extract fields of the other data source
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)

      Full join another Queryable instance, similar to SQL's `full join`

      Parameters:
        `queryable` - another Queryable instance
        `joiner` - join condition
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### public Queryable<Tuple2<?, Queryable<T>>> groupBy(Function<? super T, ?> classifier, Predicate<? super Tuple2<?, Queryable<? extends T>>> having)

      Group by Queryable instance, similar to SQL's `group by`

      Parameters:
        `classifier` - the classifier for group by
        `having` - the filter condition
      Returns:
        the result of group by
      Since:
        4.0.0

    - #### public Queryable<Tuple2<?, Queryable<T>>> groupBy(Function<? super T, ?> classifier)

      Group by Queryable instance without `having` clause, similar to SQL's `group by`

      Parameters:
        `classifier` - the classifier for group by
      Returns:
        the result of group by
      Since:
        4.0.0

    - #### <K> public Queryable<GroupResult<K, T>> groupByInto(Function<? super T, ? extends K> classifier, Predicate<? super GroupResult<K, T>> having)

      Group by Queryable instance, returning GroupResult instances for use with the `groupby...into` syntax.

      Parameters:
        `classifier` - the classifier for group by
        `having` - the filter condition (may be null)
      Type Parameters:
        `K` - the type of the group key
      Returns:
        the result of group by as GroupResult instances
      Since:
        6.0.0

    - #### <K> public Queryable<GroupResult<K, T>> groupByInto(Function<? super T, ? extends K> classifier)

      Group by Queryable instance without `having` clause, returning GroupResult instances.

      Parameters:
        `classifier` - the classifier for group by
      Type Parameters:
        `K` - the type of the group key
      Returns:
        the result of group by as GroupResult instances
      Since:
        6.0.0

    - #### <U> public Queryable<Tuple2<T, U>> innerHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)

      Inner hash join another Queryable instance, similar to SQL's `inner hash join`. Note: Inner hash join requires equijoin predicate, e.g. `on a == b`

      Parameters:
        `queryable` - another Queryable instance
        `fieldsExtractor1` - extract fields of one data source
        `fieldsExtractor2` - extract fields of the other data source
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)

      Inner join another Queryable instance, similar to SQL's `inner join`

      Parameters:
        `queryable` - another Queryable instance
        `joiner` - join condition
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### public Queryable<T> intersect(Queryable<? extends T> queryable)

      Intersect another Queryable instance, similar to SQL's `intersect`

      Parameters:
        `queryable` - the other Queryable instance
      Returns:
        the intersect result
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> leftHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)

      Left hash join another Queryable instance, similar to SQL's `left hash join`

      Parameters:
        `queryable` - another Queryable instance
        `fieldsExtractor1` - extract fields of one data source
        `fieldsExtractor2` - extract fields of the other data source
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)

      Left join another Queryable instance, similar to SQL's `left join`

      Parameters:
        `queryable` - another Queryable instance
        `joiner` - join condition
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### public Queryable<T> limit(long offset, long size)

      Paginate Queryable instance, similar to MySQL's `limit`

      Parameters:
        `offset` - the start position
        `size` - the size to take
      Returns:
        the result of paginating
      Since:
        4.0.0

    - #### public Queryable<T> limit(long size)

      Paginate Queryable instance, similar to MySQL's `limit`

      Parameters:
        `size` - the size to take
      Returns:
        the result of paginating
      Since:
        4.0.0

    - #### <U> public List<U> list(Function<? super T, ? extends U> mapper)

      Aggregate function `list`. There is no equivalent in standard SQL but various databases support a similar concept named: `list`, `listagg`, or `array_agg`.

      Parameters:
        `mapper` - choose the field to include in the list
      Type Parameters:
        `U` - the field type
      Returns:
        aggregate list result
      Since:
        4.0.14

    - #### <U extends Comparable<? super U>> public U max(Function<? super T, ? extends U> mapper)

      Aggregate function `max`, similar to SQL's `max`

      Parameters:
        `mapper` - choose the field to find the maximum
      Type Parameters:
        `U` - the field type
      Returns:
        min result
      Since:
        4.0.0

    - #### public BigDecimal median(Function<? super T, ? extends Number> mapper)

      Aggregate function `median`, similar to SQL's `median`

      Parameters:
        `mapper` - choose the field to median
      Returns:
        median result
      Since:
        4.0.0

    - #### <U extends Comparable<? super U>> public U min(Function<? super T, ? extends U> mapper)

      Aggregate function `min`, similar to SQL's `min`

      Parameters:
        `mapper` - choose the field to find the minimum
      Type Parameters:
        `U` - the field type
      Returns:
        min result
      Since:
        4.0.0

    - #### public Queryable<T> minus(Queryable<? extends T> queryable)

      Minus another Queryable instance, similar to SQL's `minus`

      Parameters:
        `queryable` - the other Queryable instance
      Returns:
        the minus result
      Since:
        4.0.0

    - #### <U extends Comparable<? super U>> public Queryable<T> orderBy(Order<? super T, ? extends U> orders)

      Sort Queryable instance, similar to SQL's `order by`

      Parameters:
        `orders` - the order rules for sorting
      Type Parameters:
        `U` - the type of field to sort
      Returns:
        the result of order by
      Since:
        4.0.0

    - #### <U extends Comparable<? super U>> public Queryable<T> orderBy(List<? extends Order<? super T, ? extends U>> orders)

      Sort Queryable instance, similar to SQL's `order by`

      Parameters:
        `orders` - the order rules for sorting
      Type Parameters:
        `U` - the type of field to sort
      Returns:
        the result of order by
      Since:
        4.0.0

    - #### <U extends Comparable<? super U>> public Window<T> over(Tuple2<T, Long> currentRecord, WindowDefinition<T, U> windowDefinition)

      Open window for current record

      Parameters:
        `currentRecord` - current record
        `windowDefinition` - window definition
      Type Parameters:
        `U` - the type of window value
      Returns:
        the window

    - #### <U> public Queryable<Tuple2<T, U>> rightHashJoin(Queryable<? extends U> queryable, Function<? super T, ?> fieldsExtractor1, Function<? super U, ?> fieldsExtractor2)

      Right hash join another Queryable instance, similar to SQL's `right join`

      Parameters:
        `queryable` - another Queryable instance
        `fieldsExtractor1` - extract fields of one data source
        `fieldsExtractor2` - extract fields of the other data source
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### <U> public Queryable<Tuple2<T, U>> rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T, ? super U> joiner)

      Right join another Queryable instance, similar to SQL's `right join`

      Parameters:
        `queryable` - another Queryable instance
        `joiner` - join condition
      Type Parameters:
        `U` - the type of element from another Queryable instance
      Returns:
        the join result
      Since:
        4.0.0

    - #### <U> public Queryable<U> select(BiFunction<? super T, ? super Queryable<? extends T>, ? extends U> mapper)

      Project Queryable instance, similar to SQL's `select`

      Parameters:
        `mapper` - project fields
      Type Parameters:
        `U` - the type of project record
      Returns:
        the result of projecting
      Since:
        4.0.0

    - #### public long size()

      Returns the count of elements of the Queryable instance

      Returns:
        the count of elements of the Queryable instance
      Since:
        4.0.0

    - #### public BigDecimal stdev(Function<? super T, ? extends Number> mapper)

      Aggregate function `stdev`, similar to SQL's `stdev`

      Parameters:
        `mapper` - choose the field to calculate the statistical standard deviation
      Returns:
        statistical standard deviation
      Since:
        4.0.0

    - #### public BigDecimal stdevp(Function<? super T, ? extends Number> mapper)

      Aggregate function `stdevp`, similar to SQL's `stdevp`

      Parameters:
        `mapper` - choose the field to calculate the statistical standard deviation for the population
      Returns:
        statistical standard deviation for the population
      Since:
        4.0.0

    - #### public Stream<T> stream()

      Create Stream<T> object for the Queryable instance

      Returns:
        the result stream
      Since:
        4.0.0

    - #### public BigDecimal sum(Function<? super T, ? extends Number> mapper)

      Aggregate function `sum`, similar to SQL's `sum`

      Parameters:
        `mapper` - choose the field to sum
      Returns:
        sum result
      Since:
        4.0.0

    - #### public List<T> toList()

      Convert the Queryable instance to List<T> instance

      Returns:
        the result list
      Since:
        4.0.0

    - #### public Queryable<T> union(Queryable<? extends T> queryable)

      Union another Queryable instance, similar to SQL's `union`

      Parameters:
        `queryable` - the other Queryable instance
      Returns:
        the union result
      Since:
        4.0.0

    - #### public Queryable<T> unionAll(Queryable<? extends T> queryable)

      Union all another Queryable instance, similar to SQL's `union all`

      Parameters:
        `queryable` - the other Queryable instance
      Returns:
        the union all result
      Since:
        4.0.0

    - #### public BigDecimal var(Function<? super T, ? extends Number> mapper)

      Aggregate function `var`, similar to SQL's `var`

      Parameters:
        `mapper` - choose the field to calculate the statistical variance
      Returns:
        statistical variance
      Since:
        4.0.0

    - #### public BigDecimal varp(Function<? super T, ? extends Number> mapper)

      Aggregate function `varp`, similar to SQL's `varp`

      Parameters:
        `mapper` - choose the field to calculate the statistical variance for the population
      Returns:
        statistical variance for the population
      Since:
        4.0.0

    - #### public Queryable<T> where(Predicate<? super T> filter)

      Filter Queryable instance via some condition, similar to SQL's `where`

      Parameters:
        `filter` - the filter condition
      Returns:
        filter result
      Since:
        4.0.0