Interface Queryable<T>
-
- Type Parameters:
T- the type of Queryable element
public interface Queryable<T>Represents the queryable objects, e.g. Java collections- Since:
- 4.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classQueryable.Order<T,U extends Comparable<? super U>>Represents an order rule
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <U> Uagg(Function<? super Queryable<? extends T>,? extends U> mapper)The most powerful aggregate function in GINQ, it will receive the grouped result(Queryableinstance) and apply any processingBigDecimalavg(Function<? super T,? extends Number> mapper)Aggregate functionavg, similar to SQL'savgLongcount()Aggreate functioncount, similar to SQL'scount<U> Longcount(Function<? super T,? extends U> mapper)Aggregate functioncount, similar to SQL'scountNote: if the chosen field isnull, the field will not be counted<U> Queryable<Tuple2<T,U>>crossJoin(Queryable<? extends U> queryable)Cross join anotherQueryableinstance, similar to SQL'scross joinQueryable<T>distinct()Eliminate duplicated records, similar to SQL'sdistinctdefault booleanexists()Check if the result is empty, similar to SQL'sexistsstatic <T> Queryable<T>from(Iterable<T> iterable)Factory method to createQueryableinstancestatic <T> Queryable<T>from(Stream<T> sourceStream)Factory method to createQueryableinstancestatic <T> Queryable<T>from(Queryable<T> queryable)Returns the originalQueryableinstance directlystatic <T> Queryable<T>from(T[] array)Factory method to createQueryableinstance<U> Queryable<Tuple2<T,U>>fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)Full join anotherQueryableinstance, similar to SQL'sfull joindefault <K> Queryable<Tuple2<K,Queryable<T>>>groupBy(Function<? super T,? extends K> classifier)<K> Queryable<Tuple2<K,Queryable<T>>>groupBy(Function<? super T,? extends K> classifier, Predicate<? super Tuple2<? extends K,Queryable<? extends T>>> having)Group byQueryableinstance, similar to SQL'sgroup by<U> Queryable<Tuple2<T,U>>innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)Inner join anotherQueryableinstance, similar to SQL'sinner joinQueryable<T>intersect(Queryable<? extends T> queryable)Intersect anotherQueryableinstance, similar to SQL'sintersect<U> Queryable<Tuple2<T,U>>leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)Left join anotherQueryableinstance, similar to SQL'sleft joindefault Queryable<T>limit(long size)PaginateQueryableinstance, similar to MySQL'slimitQueryable<T>limit(long offset, long size)PaginateQueryableinstance, similar to MySQL'slimit<U extends Comparable<? super U>>
Umax(Function<? super T,? extends U> mapper)Aggregate functionmax, similar to SQL'smax<U extends Comparable<? super U>>
Umin(Function<? super T,? extends U> mapper)Aggregate functionmin, similar to SQL'sminQueryable<T>minus(Queryable<? extends T> queryable)Minus anotherQueryableinstance, similar to SQL'sminus<U extends Comparable<? super U>>
Queryable<T>orderBy(Queryable.Order<? super T,? extends U>... orders)SortQueryableinstance, similar to SQL'sorder by<U> Queryable<Tuple2<T,U>>rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)Right join anotherQueryableinstance, similar to SQL'sright join<U> Queryable<U>select(Function<? super T,? extends U> mapper)ProjectQueryableinstance, similar to SQL'sselectlongsize()Returns the count of elements of theQueryableinstancedefault Stream<T>stream()BigDecimalsum(Function<? super T,? extends Number> mapper)Aggregate functionsum, similar to SQL'ssumList<T>toList()default Queryable<T>union(Queryable<? extends T> queryable)Union anotherQueryableinstance, similar to SQL'sunionQueryable<T>unionAll(Queryable<? extends T> queryable)Union all anotherQueryableinstance, similar to SQL'sunion allQueryable<T>where(Predicate<? super T> filter)FilterQueryableinstance via some condition, similar to SQL'swhere
-
-
-
Method Detail
-
from
static <T> Queryable<T> from(Iterable<T> iterable)
Factory method to createQueryableinstance
-
from
static <T> Queryable<T> from(T[] array)
Factory method to createQueryableinstance- Type Parameters:
T- the type of element- Parameters:
array- array object- Returns:
- the
Queryableinstance - Since:
- 4.0.0
-
from
static <T> Queryable<T> from(Stream<T> sourceStream)
Factory method to createQueryableinstance- Type Parameters:
T- the type of element- Parameters:
sourceStream- stream object- Returns:
- the
Queryableinstance - Since:
- 4.0.0
-
from
static <T> Queryable<T> from(Queryable<T> queryable)
Returns the originalQueryableinstance directly- Type Parameters:
T- the type of element- Parameters:
queryable- queryable object- Returns:
- the
Queryableinstance - Since:
- 4.0.0
-
innerJoin
<U> Queryable<Tuple2<T,U>> innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Inner join anotherQueryableinstance, similar to SQL'sinner join
-
leftJoin
<U> Queryable<Tuple2<T,U>> leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Left join anotherQueryableinstance, similar to SQL'sleft join
-
rightJoin
<U> Queryable<Tuple2<T,U>> rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Right join anotherQueryableinstance, similar to SQL'sright join
-
fullJoin
<U> Queryable<Tuple2<T,U>> fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Full join anotherQueryableinstance, similar to SQL'sfull join
-
crossJoin
<U> Queryable<Tuple2<T,U>> crossJoin(Queryable<? extends U> queryable)
Cross join anotherQueryableinstance, similar to SQL'scross join
-
where
Queryable<T> where(Predicate<? super T> filter)
FilterQueryableinstance via some condition, similar to SQL'swhere- Parameters:
filter- the filter condition- Returns:
- filter result
- Since:
- 4.0.0
-
groupBy
<K> Queryable<Tuple2<K,Queryable<T>>> groupBy(Function<? super T,? extends K> classifier, Predicate<? super Tuple2<? extends K,Queryable<? extends T>>> having)
Group byQueryableinstance, similar to SQL'sgroup by- Type Parameters:
K- the type of group key- Parameters:
classifier- the classifier for group byhaving- the filter condition- Returns:
- the result of group by
- Since:
- 4.0.0
-
groupBy
default <K> Queryable<Tuple2<K,Queryable<T>>> groupBy(Function<? super T,? extends K> classifier)
- Type Parameters:
K- the type of group key- Parameters:
classifier- the classifier for group by- Returns:
- the result of group by
- Since:
- 4.0.0
-
orderBy
<U extends Comparable<? super U>> Queryable<T> orderBy(Queryable.Order<? super T,? extends U>... orders)
SortQueryableinstance, similar to SQL'sorder by- Type Parameters:
U- the type of field to sort- Parameters:
orders- the order rules for sorting- Returns:
- the result of order by
- Since:
- 4.0.0
-
limit
Queryable<T> limit(long offset, long size)
PaginateQueryableinstance, similar to MySQL'slimit- Parameters:
offset- the start positionsize- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
limit
default Queryable<T> limit(long size)
PaginateQueryableinstance, similar to MySQL'slimit- Parameters:
size- the size to take- Returns:
- the result of paginating
- Since:
- 4.0.0
-
select
<U> Queryable<U> select(Function<? super T,? extends U> mapper)
ProjectQueryableinstance, similar to SQL'sselect- Type Parameters:
U- the type of project record- Parameters:
mapper- project fields- Returns:
- the result of projecting
- Since:
- 4.0.0
-
exists
default boolean exists()
Check if the result is empty, similar to SQL'sexists- Returns:
- the result of checking,
trueif result is not empty, otherwisefalse
-
distinct
Queryable<T> distinct()
Eliminate duplicated records, similar to SQL'sdistinct- Returns:
- the distinct result
- Since:
- 4.0.0
-
union
default Queryable<T> union(Queryable<? extends T> queryable)
Union anotherQueryableinstance, similar to SQL'sunion- Parameters:
queryable- the otherQueryableinstance- Returns:
- the union result
- Since:
- 4.0.0
-
unionAll
Queryable<T> unionAll(Queryable<? extends T> queryable)
Union all anotherQueryableinstance, similar to SQL'sunion all- Parameters:
queryable- the otherQueryableinstance- Returns:
- the union all result
- Since:
- 4.0.0
-
intersect
Queryable<T> intersect(Queryable<? extends T> queryable)
Intersect anotherQueryableinstance, similar to SQL'sintersect- Parameters:
queryable- the otherQueryableinstance- Returns:
- the intersect result
- Since:
- 4.0.0
-
minus
Queryable<T> minus(Queryable<? extends T> queryable)
Minus anotherQueryableinstance, similar to SQL'sminus- Parameters:
queryable- the otherQueryableinstance- Returns:
- the minus result
- Since:
- 4.0.0
-
count
Long count()
Aggreate functioncount, similar to SQL'scount- Returns:
- count result
- Since:
- 4.0.0
-
count
<U> Long count(Function<? super T,? extends U> mapper)
Aggregate functioncount, similar to SQL'scountNote: if the chosen field isnull, the field will not be counted- Parameters:
mapper- choose the field to count- Returns:
- count result
- Since:
- 4.0.0
-
sum
BigDecimal sum(Function<? super T,? extends Number> mapper)
Aggregate functionsum, similar to SQL'ssum- Parameters:
mapper- choose the field to sum- Returns:
- sum result
- Since:
- 4.0.0
-
avg
BigDecimal avg(Function<? super T,? extends Number> mapper)
Aggregate functionavg, similar to SQL'savg- Parameters:
mapper- choose the field to calculate the average- Returns:
- avg result
- Since:
- 4.0.0
-
min
<U extends Comparable<? super U>> U min(Function<? super T,? extends U> mapper)
Aggregate functionmin, similar to SQL'smin- Type Parameters:
U- the field type- Parameters:
mapper- choose the field to find the minimum- Returns:
- min result
- Since:
- 4.0.0
-
max
<U extends Comparable<? super U>> U max(Function<? super T,? extends U> mapper)
Aggregate functionmax, similar to SQL'smax- Type Parameters:
U- the field type- Parameters:
mapper- choose the field to find the maximum- Returns:
- min result
- Since:
- 4.0.0
-
agg
<U> U agg(Function<? super Queryable<? extends T>,? extends U> mapper)
The most powerful aggregate function in GINQ, it will receive the grouped result(Queryableinstance) and apply any processing- Type Parameters:
U- the type aggregate result- Parameters:
mapper- map the grouped result(Queryableinstance) to aggregate result- Returns:
- aggregate result
- Since:
- 4.0.0
-
size
long size()
Returns the count of elements of theQueryableinstance- Returns:
- the count of elements of the
Queryableinstance - Since:
- 4.0.0
-
-