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 class
Queryable.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> 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 processingBigDecimal
avg(Function<? super T,? extends Number> mapper)
Aggregate functionavg
, similar to SQL'savg
Long
count()
Aggreate functioncount
, similar to SQL'scount
<U> Long
count(Function<? super T,? extends U> mapper)
Aggregate functioncount
, similar to SQL'scount
Note: if the chosen field isnull
, the field will not be counted<U> Queryable<Tuple2<T,U>>
crossJoin(Queryable<? extends U> queryable)
Cross join anotherQueryable
instance, similar to SQL'scross join
Queryable<T>
distinct()
Eliminate duplicated records, similar to SQL'sdistinct
default boolean
exists()
Check if the result is empty, similar to SQL'sexists
static <T> Queryable<T>
from(Iterable<T> iterable)
Factory method to createQueryable
instancestatic <T> Queryable<T>
from(Stream<T> sourceStream)
Factory method to createQueryable
instancestatic <T> Queryable<T>
from(Queryable<T> queryable)
Returns the originalQueryable
instance directlystatic <T> Queryable<T>
from(T[] array)
Factory method to createQueryable
instance<U> Queryable<Tuple2<T,U>>
fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Full join anotherQueryable
instance, similar to SQL'sfull join
default <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 byQueryable
instance, similar to SQL'sgroup by
<U> Queryable<Tuple2<T,U>>
innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Inner join anotherQueryable
instance, similar to SQL'sinner join
Queryable<T>
intersect(Queryable<? extends T> queryable)
Intersect anotherQueryable
instance, similar to SQL'sintersect
<U> Queryable<Tuple2<T,U>>
leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Left join anotherQueryable
instance, similar to SQL'sleft join
default Queryable<T>
limit(long size)
PaginateQueryable
instance, similar to MySQL'slimit
Queryable<T>
limit(long offset, long size)
PaginateQueryable
instance, 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'smin
Queryable<T>
minus(Queryable<? extends T> queryable)
Minus anotherQueryable
instance, similar to SQL'sminus
<U extends Comparable<? super U>>
Queryable<T>orderBy(Queryable.Order<? super T,? extends U>... orders)
SortQueryable
instance, similar to SQL'sorder by
<U> Queryable<Tuple2<T,U>>
rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Right join anotherQueryable
instance, similar to SQL'sright join
<U> Queryable<U>
select(Function<? super T,? extends U> mapper)
ProjectQueryable
instance, similar to SQL'sselect
long
size()
Returns the count of elements of theQueryable
instancedefault Stream<T>
stream()
BigDecimal
sum(Function<? super T,? extends Number> mapper)
Aggregate functionsum
, similar to SQL'ssum
List<T>
toList()
default Queryable<T>
union(Queryable<? extends T> queryable)
Union anotherQueryable
instance, similar to SQL'sunion
Queryable<T>
unionAll(Queryable<? extends T> queryable)
Union all anotherQueryable
instance, similar to SQL'sunion all
Queryable<T>
where(Predicate<? super T> filter)
FilterQueryable
instance via some condition, similar to SQL'swhere
-
-
-
Method Detail
-
from
static <T> Queryable<T> from(Iterable<T> iterable)
Factory method to createQueryable
instance
-
from
static <T> Queryable<T> from(T[] array)
Factory method to createQueryable
instance- Type Parameters:
T
- the type of element- Parameters:
array
- array object- Returns:
- the
Queryable
instance - Since:
- 4.0.0
-
from
static <T> Queryable<T> from(Stream<T> sourceStream)
Factory method to createQueryable
instance- Type Parameters:
T
- the type of element- Parameters:
sourceStream
- stream object- Returns:
- the
Queryable
instance - Since:
- 4.0.0
-
from
static <T> Queryable<T> from(Queryable<T> queryable)
Returns the originalQueryable
instance directly- Type Parameters:
T
- the type of element- Parameters:
queryable
- queryable object- Returns:
- the
Queryable
instance - Since:
- 4.0.0
-
innerJoin
<U> Queryable<Tuple2<T,U>> innerJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Inner join anotherQueryable
instance, similar to SQL'sinner join
-
leftJoin
<U> Queryable<Tuple2<T,U>> leftJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Left join anotherQueryable
instance, similar to SQL'sleft join
-
rightJoin
<U> Queryable<Tuple2<T,U>> rightJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Right join anotherQueryable
instance, similar to SQL'sright join
-
fullJoin
<U> Queryable<Tuple2<T,U>> fullJoin(Queryable<? extends U> queryable, BiPredicate<? super T,? super U> joiner)
Full join anotherQueryable
instance, similar to SQL'sfull join
-
crossJoin
<U> Queryable<Tuple2<T,U>> crossJoin(Queryable<? extends U> queryable)
Cross join anotherQueryable
instance, similar to SQL'scross join
-
where
Queryable<T> where(Predicate<? super T> filter)
FilterQueryable
instance 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 byQueryable
instance, 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)
SortQueryable
instance, 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)
PaginateQueryable
instance, 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)
PaginateQueryable
instance, 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)
ProjectQueryable
instance, 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,
true
if 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 anotherQueryable
instance, similar to SQL'sunion
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the union result
- Since:
- 4.0.0
-
unionAll
Queryable<T> unionAll(Queryable<? extends T> queryable)
Union all anotherQueryable
instance, similar to SQL'sunion all
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the union all result
- Since:
- 4.0.0
-
intersect
Queryable<T> intersect(Queryable<? extends T> queryable)
Intersect anotherQueryable
instance, similar to SQL'sintersect
- Parameters:
queryable
- the otherQueryable
instance- Returns:
- the intersect result
- Since:
- 4.0.0
-
minus
Queryable<T> minus(Queryable<? extends T> queryable)
Minus anotherQueryable
instance, similar to SQL'sminus
- Parameters:
queryable
- the otherQueryable
instance- 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'scount
Note: 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(Queryable
instance) and apply any processing- Type Parameters:
U
- the type aggregate result- Parameters:
mapper
- map the grouped result(Queryable
instance) to aggregate result- Returns:
- aggregate result
- Since:
- 4.0.0
-
size
long size()
Returns the count of elements of theQueryable
instance- Returns:
- the count of elements of the
Queryable
instance - Since:
- 4.0.0
-
-