T - type of object that is being processed by the streampublic interface JinqStream<T>
extends java.util.stream.Stream<T>
Programmers typically get access to JinqStreams through a
JinqStream provider. For example, the
org.jinq.jpa.JinqJPAStreamProvider is able to create streams of JPA
entities from a database. It is also possible to create
JinqStreams from collections and single objects.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
JinqStream.AggregateGroup<W,U,V> |
static interface |
JinqStream.AggregateSelect<U,V> |
static interface |
JinqStream.CollectBigDecimal<U> |
static interface |
JinqStream.CollectBigInteger<U> |
static interface |
JinqStream.CollectComparable<U,V extends java.lang.Comparable<V>> |
static interface |
JinqStream.CollectDouble<U> |
static interface |
JinqStream.CollectInteger<U> |
static interface |
JinqStream.CollectLong<U> |
static interface |
JinqStream.CollectNumber<U,V extends java.lang.Number & java.lang.Comparable<V>> |
static interface |
JinqStream.Join<U,V> |
static interface |
JinqStream.JoinWithSource<U,V> |
static interface |
JinqStream.Select<U,V> |
static interface |
JinqStream.SelectWithSource<U,V> |
static interface |
JinqStream.Where<U,E extends java.lang.Exception> |
static interface |
JinqStream.WhereWithSource<U,E extends java.lang.Exception> |
| Modifier and Type | Method and 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> |
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>> |
avg(JinqStream.CollectNumber<T,V> aggregate)
Finds the average of the element of a stream.
|
long |
count()
Counts the elements in the stream.
|
JinqStream<T> |
distinct() |
static <U> JinqStream<U> |
from(java.util.Collection<U> collection)
Easy way to get a JinqStream from a collection.
|
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()
Deprecated.
|
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> |
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> 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>> |
leftOuterJoin(JinqStream.Join<T,U> join)
Pairs up each entry of the stream with a stream of related elements.
|
JinqStream<T> |
limit(long n) |
<V extends java.lang.Comparable<V>> |
max(JinqStream.CollectComparable<T,V> aggregate)
Finds the largest or maximum element of a stream.
|
<V extends java.lang.Comparable<V>> |
min(JinqStream.CollectComparable<T,V> aggregate)
Finds the smallest or minimum element of a stream.
|
static <U> JinqStream<U> |
of(U value)
Creates a JinqStream containing a single object.
|
void |
propagateException(java.lang.Object source,
java.lang.Throwable exception)
Deprecated.
|
<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.
|
JinqStream<T> |
setHint(java.lang.String name,
java.lang.Object value)
Sets a hint on the stream for how the query should be executed
|
JinqStream<T> |
skip(long n) |
<V extends java.lang.Comparable<V>> |
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>> |
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> |
where(JinqStream.Where<T,E> test)
Filters the elements of the stream.
|
<E extends java.lang.Exception> |
where(JinqStream.WhereWithSource<T,E> test)
Filters the elements of the stream.
|
allMatch, anyMatch, builder, collect, collect, concat, empty, filter, findAny, findFirst, flatMap, flatMapToDouble, flatMapToInt, flatMapToLong, forEach, forEachOrdered, generate, iterate, map, mapToDouble, mapToInt, mapToLong, max, min, noneMatch, peek, reduce, reduce, reduce, sorted, sorted, toArray, toArray<E extends java.lang.Exception> JinqStream<T> where(JinqStream.Where<T,E> test)
JinqStream<Customer> stream = ...;
JinqStream<Customer> result = stream.where(c -> c.getName().equals("Alice"));
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.<E extends java.lang.Exception> JinqStream<T> where(JinqStream.WhereWithSource<T,E> test)
test - function applied to each element of the stream. The function is
passed an element from the stream as well as an
InQueryStreamSource. The function should return true if
the element should be kept. if the function returns false, the
element is discarded.where(Where)<U> JinqStream<U> select(JinqStream.Select<T,U> select)
JinqStream<Customer> stream = ...;
JinqStream<String> result = stream.select(c -> c.getName());
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.<U> JinqStream<U> select(JinqStream.SelectWithSource<T,U> select)
InQueryStreamSource to the select function so that the function
can create new streams of elements to use in subqueries.select(Select)<U> JinqStream<Pair<T,U>> join(JinqStream.Join<T,U> join)
JinqStream<Country> stream = ...;
JinqStream<Pair<Country, City>> result =
stream.join(c -> JinqStream.from(c.getCities()));
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.<U> JinqStream<Pair<T,U>> join(JinqStream.JoinWithSource<T,U> join)
InQueryStreamSource to the join function so
that the function can join elements with unrelated streams of entities
from a database.join(Join)<U> JinqStream<Pair<T,U>> leftOuterJoin(JinqStream.Join<T,U> join)
JinqStream<Country> stream = ...;
JinqStream<Pair<Country, Mountain>> result =
stream.join(c -> JinqStream.from(c.getMountain()));
JinqStream<Pair<Country, Mountain>> result =
stream.join(c -> JinqStream.of(c.getHighestMountain()));
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.join(Join)<U,V> JinqStream<Pair<U,V>> group(JinqStream.Select<T,U> select, JinqStream.AggregateGroup<U,T,V> aggregate)
JinqStream<City> stream = ...;
JinqStream<Pair<String, Long>> result =
stream.group(c -> c.getCountry(), (key, cities) -> cities.count());
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.<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)
group(Select, AggregateGroup)<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)
group(Select, AggregateGroup)<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)
group(Select, AggregateGroup)java.lang.Long sumInteger(JinqStream.CollectInteger<T> aggregate)
JinqStream<City> stream = ...;
long totalPopulation = stream.sumInteger(c -> c.getPopulation());
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.java.lang.Long sumLong(JinqStream.CollectLong<T> aggregate)
sumInteger(CollectInteger)java.lang.Double sumDouble(JinqStream.CollectDouble<T> aggregate)
sumInteger(CollectInteger)java.math.BigDecimal sumBigDecimal(JinqStream.CollectBigDecimal<T> aggregate)
sumInteger(CollectInteger)java.math.BigInteger sumBigInteger(JinqStream.CollectBigInteger<T> aggregate)
sumInteger(CollectInteger)<V extends java.lang.Comparable<V>> V max(JinqStream.CollectComparable<T,V> aggregate)
JinqStream<Student> stream = ...;
Date birthdayOfYoungest = stream.max(s -> s.getBirthday());
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.<V extends java.lang.Comparable<V>> V min(JinqStream.CollectComparable<T,V> aggregate)
JinqStream<Student> stream = ...;
Date birthdayOfYoungest = stream.max(s -> s.getBirthday());
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.max(CollectComparable)<V extends java.lang.Number & java.lang.Comparable<V>> java.lang.Double avg(JinqStream.CollectNumber<T,V> aggregate)
JinqStream<Student> stream = ...;
double averageAge = stream.avg(s -> s.getage());
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<U,V> Pair<U,V> aggregate(JinqStream.AggregateSelect<T,U> aggregate1, JinqStream.AggregateSelect<T,V> aggregate2)
JinqStream<City> stream = ...;
Pair<Long, Long> result = stream.aggregate(
c -> c.sumInteger(c.getPopulation()),
c -> c.count());
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<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.Comparable<V>> JinqStream<T> sortedBy(JinqStream.CollectComparable<T,V> sortField)
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<V extends java.lang.Comparable<V>> JinqStream<T> sortedDescendingBy(JinqStream.CollectComparable<T,V> sortField)
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 elementsortedBy(CollectComparable)JinqStream<T> skip(long n)
skip in interface java.util.stream.Stream<T>JinqStream<T> limit(long n)
limit in interface java.util.stream.Stream<T>JinqStream<T> distinct()
distinct in interface java.util.stream.Stream<T>long count()
count in interface java.util.stream.Stream<T>Stream.count()T getOnlyValue()
java.util.NoSuchElementException - stream contains zero or more than one elementjava.util.List<T> toList()
java.lang.String getDebugQueryString()
null if Jinq cannot find
a database query equivalent to the contents of the stream.@Deprecated
void propagateException(java.lang.Object source,
java.lang.Throwable exception)
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@Deprecated java.util.Collection<java.lang.Throwable> getExceptions()
JinqStream<T> setHint(java.lang.String name, java.lang.Object value)
name - name of the hint to changevalue - value to assign to the hintstatic <U> JinqStream<U> from(java.util.Collection<U> collection)
static <U> JinqStream<U> of(U value)
of in interface java.util.stream.Stream<T>Copyright © 2014. All Rights Reserved.