Package org.jinq.orm.stream
Class NonQueryJinqStream<T>
- java.lang.Object
-
- org.jinq.orm.stream.LazyWrappedStream<T>
-
- org.jinq.orm.stream.NonQueryJinqStream<T>
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,java.util.stream.BaseStream<T,java.util.stream.Stream<T>>
,java.util.stream.Stream<T>
,JinqStream<T>
- Direct Known Subclasses:
QueryJinqStream
public class NonQueryJinqStream<T> extends LazyWrappedStream<T> implements JinqStream<T>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NonQueryJinqStream.IteratorTee<T>
-
Nested classes/interfaces inherited from interface org.jinq.orm.stream.JinqStream
JinqStream.AggregateGroup<W,U,V>, JinqStream.AggregateSelect<U,V>, JinqStream.CollectBigDecimal<U>, JinqStream.CollectBigInteger<U>, JinqStream.CollectComparable<U,V extends java.lang.Comparable<V>>, JinqStream.CollectDouble<U>, JinqStream.CollectInteger<U>, JinqStream.CollectLong<U>, JinqStream.CollectNumber<U,V extends java.lang.Number & java.lang.Comparable<V>>, JinqStream.Join<U,V>, JinqStream.JoinToIterable<U,V>, JinqStream.JoinWithSource<U,V>, JinqStream.Select<U,V>, JinqStream.SelectWithSource<U,V>, JinqStream.Where<U,E extends java.lang.Exception>, JinqStream.WhereForOn<U,V>, JinqStream.WhereWithSource<U,E extends java.lang.Exception>
-
-
Field Summary
Fields Modifier and Type Field Description protected InQueryStreamSource
inQueryStreamSource
protected java.util.Map<java.lang.Object,java.lang.Throwable>
recordedExceptions
-
Constructor Summary
Constructors Constructor Description NonQueryJinqStream(java.util.stream.Stream<T> wrapped)
NonQueryJinqStream(java.util.stream.Stream<T> wrapped, InQueryStreamSource inQueryStreamSource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <U,V>
Pair<U,V>aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2)
Calculates more than one aggregate function over the elements of the stream.<U,V,W>
Tuple3<U,V,W>aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2, JinqStream.AggregateSelect<T,W> aggregate3)
<U,V,W,X>
Tuple4<U,V,W,X>aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2, JinqStream.AggregateSelect<T,W> aggregate3, JinqStream.AggregateSelect<T,X> aggregate4)
<U,V,W,X,Y>
Tuple5<U,V,W,X,Y>aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2, JinqStream.AggregateSelect<T,W> aggregate3, JinqStream.AggregateSelect<T,X> aggregate4, JinqStream.AggregateSelect<T,Y> aggregate5)
<V extends java.lang.Number & java.lang.Comparable<V>>
java.lang.Doubleavg(JinqStream.CollectNumber<T,V> aggregate)
Finds the average of the elements of a stream.<U> JinqStream<Pair<T,U>>
crossJoin(JinqStream<U> join)
Performs a full cross-join of the elements of two streams.JinqStream<T>
distinct()
java.util.Optional<T>
findFirst()
A convenience method for limiting the stream to one element and then returning that element as an Optional.java.util.Optional<T>
findOne()
A convenience method for getting the contents of a stream when it contains 0 or 1 values.java.lang.String
getDebugQueryString()
Returns the query that Jinq will send to the database to generate the values of the stream.java.util.Collection<java.lang.Throwable>
getExceptions()
T
getOnlyValue()
If the stream contains only a single value, this method will return that value.<U,V>
JinqStream<Pair<U,V>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate)
Groups together elements from the stream that share a common key.<U,V,W>
JinqStream<Tuple3<U,V,W>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2)
Calculates two aggregate values instead of one aggregate value for grouped stream elements.<U,V,W,X>
JinqStream<Tuple4<U,V,W,X>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3)
Calculates three aggregate values instead of one aggregate value for grouped stream elements.<U,V,W,X,Y>
JinqStream<Tuple5<U,V,W,X,Y>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4)
Calculates four aggregate values instead of one aggregate value for grouped stream elements.<U,V,W,X,Y,Z>
JinqStream<Tuple6<U,V,W,X,Y,Z>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4, JinqStream.AggregateGroup<U,T,Z> aggregate5)
Calculates five aggregate values instead of one aggregate value for grouped stream elements.<U,V,W,X,Y,Z,A>
JinqStream<Tuple7<U,V,W,X,Y,Z,A>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4, JinqStream.AggregateGroup<U,T,Z> aggregate5, JinqStream.AggregateGroup<U,T,A> aggregate6)
Calculates six aggregate values instead of one aggregate value for grouped stream elements.<U,V,W,X,Y,Z,A,B>
JinqStream<Tuple8<U,V,W,X,Y,Z,A,B>>group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4, JinqStream.AggregateGroup<U,T,Z> aggregate5, JinqStream.AggregateGroup<U,T,A> aggregate6, JinqStream.AggregateGroup<U,T,B> aggregate7)
Calculates seven aggregate values instead of one aggregate value for grouped stream elements.protected <U,W extends Tuple>
JinqStream<W>groupToTuple(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,?>[] aggregates)
<U> JinqStream<Pair<T,U>>
join(JinqStream.Join<T,U> join)
Pairs up each entry of the stream with a stream of related elements.<U> JinqStream<Pair<T,U>>
join(JinqStream.JoinWithSource<T,U> join)
Pairs up each entry of the stream with a stream of related elements.<U> JinqStream<Pair<T,U>>
joinList(JinqStream.JoinToIterable<T,U> join)
A variant of join() that can be used if you want to join to a collection without the trouble of converting it to a JinqStream first.<U> JinqStream<Pair<T,U>>
leftOuterJoin(JinqStream.Join<T,U> join)
Pairs up each entry of the stream with a stream of related elements.<U> JinqStream<Pair<T,U>>
leftOuterJoin(JinqStream.JoinWithSource<T,U> join, JinqStream.WhereForOn<T,U> on)
Pairs up each entry of the stream with a stream of related elements.<U> JinqStream<Pair<T,U>>
leftOuterJoinList(JinqStream.JoinToIterable<T,U> join)
A variant of leftOuterJoin() that can be used if you want to join to a collection without the trouble of converting it to a JinqStream first.JinqStream<T>
limit(long n)
<V extends java.lang.Comparable<V>>
Vmax(JinqStream.CollectComparable<T,V> aggregate)
Finds the largest or maximum element of a stream.<V extends java.lang.Comparable<V>>
Vmin(JinqStream.CollectComparable<T,V> aggregate)
Finds the smallest or minimum element of a stream.void
propagateException(java.lang.Object source, java.lang.Throwable exception)
Used for recording an exception that occurred during processing somewhere in the stream chain.<U> JinqStream<U>
select(JinqStream.Select<T,U> select)
Transforms the elements in the stream.<U> JinqStream<U>
select(JinqStream.SelectWithSource<T,U> select)
Transforms the elements in the stream.<U> JinqStream<U>
selectAll(JinqStream.Join<T,U> select)
Transforms the elements in the stream.<U> JinqStream<U>
selectAll(JinqStream.JoinWithSource<T,U> select)
Transforms the elements in the stream.<U> JinqStream<U>
selectAllList(JinqStream.JoinToIterable<T,U> select)
A variant of selectAll() that can be used if you want to join to a collection without the trouble of converting it to a JinqStream first.JinqStream<T>
setHint(java.lang.String name, java.lang.Object value)
Sets a hint on the stream for how the query should be executedJinqStream<T>
skip(long n)
<V extends java.lang.Comparable<V>>
JinqStream<T>sortedBy(JinqStream.CollectComparable<T,V> sortField)
Sorts the elements of a stream in ascending order based on the value returned.<V extends java.lang.Comparable<V>>
JinqStream<T>sortedDescendingBy(JinqStream.CollectComparable<T,V> sortField)
Sorts the elements of a stream in descending order based on the value returned.java.math.BigDecimal
sumBigDecimal(JinqStream.CollectBigDecimal<T> aggregate)
java.math.BigInteger
sumBigInteger(JinqStream.CollectBigInteger<T> aggregate)
java.lang.Double
sumDouble(JinqStream.CollectDouble<T> aggregate)
java.lang.Long
sumInteger(JinqStream.CollectInteger<T> aggregate)
Calculates a sum over the elements of a stream.java.lang.Long
sumLong(JinqStream.CollectLong<T> aggregate)
java.util.List<T>
toList()
Convenience method that collects the stream contents into a List.<E extends java.lang.Exception>
JinqStream<T>where(JinqStream.Where<T,E> test)
Filters the elements of the stream.<E extends java.lang.Exception>
JinqStream<T>where(JinqStream.WhereWithSource<T,E> test)
Filters the elements of the stream.protected <U> JinqStream<U>
wrap(java.util.stream.Stream<U> toWrap)
Allows subclasses to wrap streams generated by this class with wrappers that provide additional functionality.-
Methods inherited from class org.jinq.orm.stream.LazyWrappedStream
allMatch, anyMatch, close, collect, collect, count, createWrappedStream, filter, findAny, flatMap, flatMapToDouble, flatMapToInt, flatMapToLong, forEach, forEachOrdered, isParallel, iterator, map, mapToDouble, mapToInt, mapToLong, max, min, noneMatch, onClose, parallel, peek, realizeStream, reduce, reduce, reduce, sequential, sorted, sorted, spliterator, toArray, toArray, unordered
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.stream.BaseStream
close, isParallel, iterator, onClose, parallel, sequential, spliterator, unordered
-
Methods inherited from interface org.jinq.orm.stream.JinqStream
count, exists
-
Methods inherited from interface java.util.stream.Stream
allMatch, anyMatch, collect, collect, dropWhile, filter, findAny, flatMap, flatMapToDouble, flatMapToInt, flatMapToLong, forEach, forEachOrdered, map, mapToDouble, mapToInt, mapToLong, max, min, noneMatch, peek, reduce, reduce, reduce, sorted, sorted, takeWhile, toArray, toArray
-
-
-
-
Field Detail
-
inQueryStreamSource
protected InQueryStreamSource inQueryStreamSource
-
recordedExceptions
protected java.util.Map<java.lang.Object,java.lang.Throwable> recordedExceptions
-
-
Constructor Detail
-
NonQueryJinqStream
public NonQueryJinqStream(java.util.stream.Stream<T> wrapped)
-
NonQueryJinqStream
public NonQueryJinqStream(java.util.stream.Stream<T> wrapped, InQueryStreamSource inQueryStreamSource)
-
-
Method Detail
-
wrap
protected <U> JinqStream<U> wrap(java.util.stream.Stream<U> toWrap)
Description copied from class:LazyWrappedStream
Allows subclasses to wrap streams generated by this class with wrappers that provide additional functionality.- Overrides:
wrap
in classLazyWrappedStream<T>
-
where
public <E extends java.lang.Exception> JinqStream<T> where(JinqStream.Where<T,E> test)
Description copied from interface:JinqStream
Filters the elements of the stream.JinqStream<Customer> stream = ...; JinqStream<Customer> result = stream.where(c -> c.getName().equals("Alice"));
- Specified by:
where
in interfaceJinqStream<T>
- Parameters:
test
- function applied to the elements of the stream. When passed an element from the stream, the function should return true if the element should be kept. if the function returns false, the element is discarded.- Returns:
- a new stream that returns only the elements satisfying the filter
-
where
public <E extends java.lang.Exception> JinqStream<T> where(JinqStream.WhereWithSource<T,E> test)
Description copied from interface:JinqStream
Filters the elements of the stream. This version allows the filter function to take a second parameter with an InQueryStreamSource. This lets the function create new streams of elements that it can use in subqueries.- Specified by:
where
in interfaceJinqStream<T>
- Parameters:
test
- function applied to each element of the stream. The function is passed an element from the stream as well as anInQueryStreamSource
. The function should return true if the element should be kept. if the function returns false, the element is discarded.- Returns:
- a new stream that returns only the elements satisfying the filter
- See Also:
JinqStream.where(Where)
-
select
public <U> JinqStream<U> select(JinqStream.Select<T,U> select)
Description copied from interface:JinqStream
Transforms the elements in the stream. The method allows you to rewrite each element from the stream, so that they contain only certain fields or to do some calculation based on the values of the fields.JinqStream<Customer> stream = ...; JinqStream<String> result = stream.select(c -> c.getName());
- Specified by:
select
in interfaceJinqStream<T>
- Parameters:
select
- function applied to the elements of the stream. When passed an element from the stream, the function should return a new value that should be used instead of the element in the stream.- Returns:
- a new stream that uses only the new rewritten stream elements
-
select
public <U> JinqStream<U> select(JinqStream.SelectWithSource<T,U> select)
Description copied from interface:JinqStream
Transforms the elements in the stream. This version also passes anInQueryStreamSource
to the select function so that the function can create new streams of elements to use in subqueries.- Specified by:
select
in interfaceJinqStream<T>
- See Also:
JinqStream.select(Select)
-
selectAll
public <U> JinqStream<U> selectAll(JinqStream.Join<T,U> select)
Description copied from interface:JinqStream
Transforms the elements in the stream. The method allows you to rewrite each element from the stream, so that they contain only certain fields or to do some calculation based on the values of the fields. Unlike a normal select(), this method allows you to return a stream of elements. The stream elements will all be added to the final stream.JinqStream<Country> stream = ...; JinqStream<City> result = stream.selectAll(c -> JinqStream.from(c.getCities()));
- Specified by:
selectAll
in interfaceJinqStream<T>
- Parameters:
select
- function applied to the elements of the stream. When passed an element from the stream, the function should return a stream of new values that will be flattened and placed in the new stream- Returns:
- a new stream that uses only the new rewritten stream elements
- See Also:
JinqStream.select(Select)
-
selectAll
public <U> JinqStream<U> selectAll(JinqStream.JoinWithSource<T,U> select)
Description copied from interface:JinqStream
Transforms the elements in the stream. This version also passes anInQueryStreamSource
to the select function so that the function can create new streams of elements to use in subqueries.- Specified by:
selectAll
in interfaceJinqStream<T>
- See Also:
JinqStream.selectAll(Join)
-
selectAllList
public <U> JinqStream<U> selectAllList(JinqStream.JoinToIterable<T,U> select)
Description copied from interface:JinqStream
A variant of selectAll() that can be used if you want to join to a collection without the trouble of converting it to a JinqStream first.JinqStream<Country> stream = ...; JinqStream<City> result = stream.selectAll(c -> c.getCities());
- Specified by:
selectAllList
in interfaceJinqStream<T>
- Parameters:
select
- function applied to the elements of the stream. When passed an element from the stream, the function should return a collection of new values that will be flattened and placed in the new stream- Returns:
- a new stream that uses only the new rewritten stream elements
- See Also:
JinqStream.selectAll(Join)
-
join
public <U> JinqStream<Pair<T,U>> join(JinqStream.Join<T,U> join)
Description copied from interface:JinqStream
Pairs up each entry of the stream with a stream of related elements.JinqStream<Country> stream = ...; JinqStream<Pair<Country, City>> result = stream.join(c -> JinqStream.from(c.getCities()));
- Specified by:
join
in interfaceJinqStream<T>
- Parameters:
join
- function applied to the elements of the stream. When passed an element from the stream, the function should return a stream of values that should be paired up with that stream element.- Returns:
- a new stream with the paired up elements
-
join
public <U> JinqStream<Pair<T,U>> join(JinqStream.JoinWithSource<T,U> join)
Description copied from interface:JinqStream
Pairs up each entry of the stream with a stream of related elements. This version also passes anInQueryStreamSource
to the join function so that the function can join elements with unrelated streams of entities from a database.- Specified by:
join
in interfaceJinqStream<T>
- See Also:
JinqStream.join(Join)
-
joinList
public <U> JinqStream<Pair<T,U>> joinList(JinqStream.JoinToIterable<T,U> join)
Description copied from interface:JinqStream
A variant of join() that can be used if you want to join to a collection without the trouble of converting it to a JinqStream first.- Specified by:
joinList
in interfaceJinqStream<T>
- See Also:
JinqStream.join(Join)
-
leftOuterJoin
public <U> JinqStream<Pair<T,U>> leftOuterJoin(JinqStream.Join<T,U> join)
Description copied from interface:JinqStream
Pairs up each entry of the stream with a stream of related elements. Uses a left outer join during the pairing up process, so even if an element is not joined with anything, a pair will still be created in the output stream consisting of the element paired with null.JinqStream<Country> stream = ...; JinqStream<Pair<Country, Mountain>> result = stream.leftOuterJoin(c -> JinqStream.from(c.getMountain())); JinqStream<Pair<Country, Mountain>> result = stream.leftOuterJoin(c -> JinqStream.of(c.getHighestMountain()));
- Specified by:
leftOuterJoin
in interfaceJinqStream<T>
- Parameters:
join
- function applied to the elements of the stream. When passed an element from the stream, the function should return a stream of values that should be paired up with that stream element. The function must use a JPA association or navigational link as the base for the stream returned. Both singular or plural associations are allowed.- Returns:
- a new stream with the paired up elements
- See Also:
JinqStream.join(Join)
-
leftOuterJoinList
public <U> JinqStream<Pair<T,U>> leftOuterJoinList(JinqStream.JoinToIterable<T,U> join)
Description copied from interface:JinqStream
A variant of leftOuterJoin() that can be used if you want to join to a collection without the trouble of converting it to a JinqStream first.- Specified by:
leftOuterJoinList
in interfaceJinqStream<T>
- See Also:
JinqStream.leftOuterJoin(Join)
-
leftOuterJoin
public <U> JinqStream<Pair<T,U>> leftOuterJoin(JinqStream.JoinWithSource<T,U> join, JinqStream.WhereForOn<T,U> on)
Description copied from interface:JinqStream
Pairs up each entry of the stream with a stream of related elements. Uses a left outer join during the pairing up process, so even if an element is not joined with anything, a pair will still be created in the output stream consisting of the element paired with null. This version also passes anInQueryStreamSource
to the join function so that the function can join elements with unrelated streams of entities from a database and an ON clause can be specified that will determine which elements from the two streams will be joined together.JinqStream<Country> stream = ...; JinqStream<Pair<Country, Mountain>> result = stream.leftOuterJoin( (c, source) -> source.stream(Mountain.class), (country, mountain) -> country.getName().equals(mountain.getCountry()));
- Specified by:
leftOuterJoin
in interfaceJinqStream<T>
- Parameters:
join
- function applied to the elements of the stream. When passed an element from the stream, the function should return a stream of values that should be paired up with that stream element. The function must use a JPA association or navigational link as the base for the stream returned. Both singular or plural associations are allowed.on
- this is a comparison function that returns true if the elements from the two streams should be joined together. It is similar to a standard where() clause except that the elements from the two streams are passed in as separate parameters for convenience (as opposed to being passed in as a pair)- Returns:
- a new stream with the paired up elements
- See Also:
JinqStream.leftOuterJoin(Join)
-
crossJoin
public <U> JinqStream<Pair<T,U>> crossJoin(JinqStream<U> join)
Description copied from interface:JinqStream
Performs a full cross-join of the elements of two streams.- Specified by:
crossJoin
in interfaceJinqStream<T>
- Parameters:
join
- other stream to perform the cross join with- Returns:
- a new stream where each element of the stream is paired up with each element of the join stream
-
groupToTuple
protected <U,W extends Tuple> JinqStream<W> groupToTuple(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,?>[] aggregates)
-
group
public <U,V> JinqStream<Pair<U,V>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate)
Description copied from interface:JinqStream
Groups together elements from the stream that share a common key. Aggregates can then be calculated over the elements in each group.JinqStream<City> stream = ...; JinqStream<Pair<String, Long>> result = stream.group(c -> c.getCountry(), (key, cities) -> cities.count());
- Specified by:
group
in interfaceJinqStream<T>
- Parameters:
select
- function applied to each element of the stream that returns the key to be used to group elements togetheraggregate
- function applied to each group and calculates an aggregate value over the group. The function is passed the key for the group and a JinqStream of elements contained inside that group. It should return the aggregate value calculated for that group.- Returns:
- a new stream containing a tuple for each group. The tuple contains the key for the group and any calculated aggregate values.
-
group
public <U,V,W> JinqStream<Tuple3<U,V,W>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2)
Description copied from interface:JinqStream
Calculates two aggregate values instead of one aggregate value for grouped stream elements.- Specified by:
group
in interfaceJinqStream<T>
- See Also:
JinqStream.group(Select, AggregateGroup)
-
group
public <U,V,W,X> JinqStream<Tuple4<U,V,W,X>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3)
Description copied from interface:JinqStream
Calculates three aggregate values instead of one aggregate value for grouped stream elements.- Specified by:
group
in interfaceJinqStream<T>
- See Also:
JinqStream.group(Select, AggregateGroup)
-
group
public <U,V,W,X,Y> JinqStream<Tuple5<U,V,W,X,Y>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4)
Description copied from interface:JinqStream
Calculates four aggregate values instead of one aggregate value for grouped stream elements.- Specified by:
group
in interfaceJinqStream<T>
- See Also:
JinqStream.group(Select, AggregateGroup)
-
group
public <U,V,W,X,Y,Z> JinqStream<Tuple6<U,V,W,X,Y,Z>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4, JinqStream.AggregateGroup<U,T,Z> aggregate5)
Description copied from interface:JinqStream
Calculates five aggregate values instead of one aggregate value for grouped stream elements.- Specified by:
group
in interfaceJinqStream<T>
- See Also:
JinqStream.group(Select, AggregateGroup)
-
group
public <U,V,W,X,Y,Z,A> JinqStream<Tuple7<U,V,W,X,Y,Z,A>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4, JinqStream.AggregateGroup<U,T,Z> aggregate5, JinqStream.AggregateGroup<U,T,A> aggregate6)
Description copied from interface:JinqStream
Calculates six aggregate values instead of one aggregate value for grouped stream elements.- Specified by:
group
in interfaceJinqStream<T>
- See Also:
JinqStream.group(Select, AggregateGroup)
-
group
public <U,V,W,X,Y,Z,A,B> JinqStream<Tuple8<U,V,W,X,Y,Z,A,B>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate1, JinqStream.AggregateGroup<U,T,W> aggregate2, JinqStream.AggregateGroup<U,T,X> aggregate3, JinqStream.AggregateGroup<U,T,Y> aggregate4, JinqStream.AggregateGroup<U,T,Z> aggregate5, JinqStream.AggregateGroup<U,T,A> aggregate6, JinqStream.AggregateGroup<U,T,B> aggregate7)
Description copied from interface:JinqStream
Calculates seven aggregate values instead of one aggregate value for grouped stream elements.- Specified by:
group
in interfaceJinqStream<T>
- See Also:
JinqStream.group(Select, AggregateGroup)
-
sumInteger
public java.lang.Long sumInteger(JinqStream.CollectInteger<T> aggregate)
Description copied from interface:JinqStream
Calculates a sum over the elements of a stream. Different sum methods are provided for calculating the sum of integer, long, double, BigDecimal, and BigInteger values.JinqStream<City> stream = ...; long totalPopulation = stream.sumInteger(c -> c.getPopulation());
- Specified by:
sumInteger
in interfaceJinqStream<T>
- Parameters:
aggregate
- function applied to each element of the stream. When passed an element of the stream, it should return the value that should be added to the sum.- Returns:
- the sum of the values returned by the function
-
sumLong
public java.lang.Long sumLong(JinqStream.CollectLong<T> aggregate)
- Specified by:
sumLong
in interfaceJinqStream<T>
- See Also:
JinqStream.sumInteger(CollectInteger)
-
sumDouble
public java.lang.Double sumDouble(JinqStream.CollectDouble<T> aggregate)
- Specified by:
sumDouble
in interfaceJinqStream<T>
- See Also:
JinqStream.sumInteger(CollectInteger)
-
sumBigDecimal
public java.math.BigDecimal sumBigDecimal(JinqStream.CollectBigDecimal<T> aggregate)
- Specified by:
sumBigDecimal
in interfaceJinqStream<T>
- See Also:
JinqStream.sumInteger(CollectInteger)
-
sumBigInteger
public java.math.BigInteger sumBigInteger(JinqStream.CollectBigInteger<T> aggregate)
- Specified by:
sumBigInteger
in interfaceJinqStream<T>
- See Also:
JinqStream.sumInteger(CollectInteger)
-
max
public <V extends java.lang.Comparable<V>> V max(JinqStream.CollectComparable<T,V> aggregate)
Description copied from interface:JinqStream
Finds the largest or maximum element of a stream.JinqStream<Student> stream = ...; Date birthdayOfYoungest = stream.max(s -> s.getBirthday());
- Specified by:
max
in interfaceJinqStream<T>
- Parameters:
aggregate
- function applied to each element of the stream. When passed an element of the stream, it should return the value that should be compared.- Returns:
- the maximum of the values returned by the function
-
min
public <V extends java.lang.Comparable<V>> V min(JinqStream.CollectComparable<T,V> aggregate)
Description copied from interface:JinqStream
Finds the smallest or minimum element of a stream.JinqStream<Student> stream = ...; Date birthdayOfOldest = stream.min(s -> s.getBirthday());
- Specified by:
min
in interfaceJinqStream<T>
- Parameters:
aggregate
- function applied to each element of the stream. When passed an element of the stream, it should return the value that should be compared.- Returns:
- the minimum of the values returned by the function
- See Also:
JinqStream.max(CollectComparable)
-
avg
public <V extends java.lang.Number & java.lang.Comparable<V>> java.lang.Double avg(JinqStream.CollectNumber<T,V> aggregate)
Description copied from interface:JinqStream
Finds the average of the elements of a stream.JinqStream<Student> stream = ...; double averageAge = stream.avg(s -> s.getage());
- Specified by:
avg
in interfaceJinqStream<T>
- Parameters:
aggregate
- function applied to each element of the stream. When passed an element of the stream, it should return the value that should be included in the average- Returns:
- the average of the values returned by the function
-
sortedBy
public <V extends java.lang.Comparable<V>> JinqStream<T> sortedBy(JinqStream.CollectComparable<T,V> sortField)
Description copied from interface:JinqStream
Sorts the elements of a stream in ascending order based on the value returned. The sort is stable, so it is possible to sort the stream multiple times in order to have multiple sort keys. The last sort becomes the primary sort key, and earlier sorts become lesser keys.- Specified by:
sortedBy
in interfaceJinqStream<T>
- Parameters:
sortField
- function applied to each element of the stream. When passed an element of the stream, it should return the value that should be used as the sorting value of the element- Returns:
- sorted stream
-
sortedDescendingBy
public <V extends java.lang.Comparable<V>> JinqStream<T> sortedDescendingBy(JinqStream.CollectComparable<T,V> sortField)
Description copied from interface:JinqStream
Sorts the elements of a stream in descending order based on the value returned.- Specified by:
sortedDescendingBy
in interfaceJinqStream<T>
- Parameters:
sortField
- function applied to each element of the stream. When passed an element of the stream, it should return the value that should be used as the sorting value of the element- Returns:
- sorted stream
- See Also:
JinqStream.sortedBy(CollectComparable)
-
skip
public JinqStream<T> skip(long n)
- Specified by:
skip
in interfaceJinqStream<T>
- Specified by:
skip
in interfacejava.util.stream.Stream<T>
- Overrides:
skip
in classLazyWrappedStream<T>
-
limit
public JinqStream<T> limit(long n)
- Specified by:
limit
in interfaceJinqStream<T>
- Specified by:
limit
in interfacejava.util.stream.Stream<T>
- Overrides:
limit
in classLazyWrappedStream<T>
-
distinct
public JinqStream<T> distinct()
- Specified by:
distinct
in interfaceJinqStream<T>
- Specified by:
distinct
in interfacejava.util.stream.Stream<T>
- Overrides:
distinct
in classLazyWrappedStream<T>
-
findOne
public java.util.Optional<T> findOne()
Description copied from interface:JinqStream
A convenience method for getting the contents of a stream when it contains 0 or 1 values. If the stream contains more than one value, an exception will be thrown. It cannot be used in subqueries.- Specified by:
findOne
in interfaceJinqStream<T>
- Returns:
- an Optional with the single element contained in the stream or an empty Optional if the stream is empty
- See Also:
Stream.findFirst()
-
findFirst
public java.util.Optional<T> findFirst()
A convenience method for limiting the stream to one element and then returning that element as an Optional. It cannot be used in subqueries.- Specified by:
findFirst
in interfaceJinqStream<T>
- Specified by:
findFirst
in interfacejava.util.stream.Stream<T>
- Overrides:
findFirst
in classLazyWrappedStream<T>
- See Also:
Stream.findFirst()
-
getOnlyValue
public T getOnlyValue()
Description copied from interface:JinqStream
If the stream contains only a single value, this method will return that value. This method is convenient for getting the results of queries that contain only a single value. It is also useful in subqueries.- Specified by:
getOnlyValue
in interfaceJinqStream<T>
- Returns:
- the single element contained in the stream
-
toList
public java.util.List<T> toList()
Description copied from interface:JinqStream
Convenience method that collects the stream contents into a List.- Specified by:
toList
in interfaceJinqStream<T>
- Returns:
- a list of all the elements from the stream
-
getDebugQueryString
public java.lang.String getDebugQueryString()
Description copied from interface:JinqStream
Returns the query that Jinq will send to the database to generate the values of the stream.- Specified by:
getDebugQueryString
in interfaceJinqStream<T>
- Returns:
- the database query string or
null
if Jinq cannot find a database query equivalent to the contents of the stream.
-
propagateException
public void propagateException(java.lang.Object source, java.lang.Throwable exception)
Description copied from interface:JinqStream
Used for recording an exception that occurred during processing somewhere in the stream chain.- Specified by:
propagateException
in interfaceJinqStream<T>
- Parameters:
source
- lambda object that caused the exception (used so that if the same lambda causes multiple exceptions, only some of them need to be recorded in order to avoid memory issues)exception
- actual exception object
-
getExceptions
public java.util.Collection<java.lang.Throwable> getExceptions()
- Specified by:
getExceptions
in interfaceJinqStream<T>
-
aggregate
public <U,V> Pair<U,V> aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2)
Description copied from interface:JinqStream
Calculates more than one aggregate function over the elements of the stream.JinqStream<City> stream = ...; Pair<Long, Long> result = stream.aggregate( c -> c.sumInteger(c.getPopulation()), c -> c.count());
- Specified by:
aggregate
in interfaceJinqStream<T>
- Parameters:
aggregate1
- a function that takes a stream and returns the first calculated aggregate value for the streamaggregate2
- a function that takes a stream and returns a second calculated aggregate value for the stream- Returns:
- a tuple of the calculated aggregate values
-
aggregate
public <U,V,W> Tuple3<U,V,W> aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2, JinqStream.AggregateSelect<T,W> aggregate3)
- Specified by:
aggregate
in interfaceJinqStream<T>
- See Also:
JinqStream.aggregate(AggregateSelect, AggregateSelect)
-
aggregate
public <U,V,W,X> Tuple4<U,V,W,X> aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2, JinqStream.AggregateSelect<T,W> aggregate3, JinqStream.AggregateSelect<T,X> aggregate4)
- Specified by:
aggregate
in interfaceJinqStream<T>
- See Also:
JinqStream.aggregate(AggregateSelect, AggregateSelect)
-
aggregate
public <U,V,W,X,Y> Tuple5<U,V,W,X,Y> aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2, JinqStream.AggregateSelect<T,W> aggregate3, JinqStream.AggregateSelect<T,X> aggregate4, JinqStream.AggregateSelect<T,Y> aggregate5)
- Specified by:
aggregate
in interfaceJinqStream<T>
- See Also:
JinqStream.aggregate(AggregateSelect, AggregateSelect)
-
setHint
public JinqStream<T> setHint(java.lang.String name, java.lang.Object value)
Description copied from interface:JinqStream
Sets a hint on the stream for how the query should be executed- Specified by:
setHint
in interfaceJinqStream<T>
- Parameters:
name
- name of the hint to changevalue
- value to assign to the hint- Returns:
- a pointer to the stream, to make it easier to chain method calls on the stream
-
-