E
- type of element.public interface Result<E> extends CloseableIterable<E>, AutoCloseable
close()
after the result is no longer needed. Entities created from
the result are still valid and can still be referenced and used. This result is active that
calls to methods return the underlying data e.g. Iterable.iterator()
, toList()
will cause the query to be executed.Modifier and Type | Method and Description |
---|---|
void |
close()
Close this result and any resources it holds.
|
<C extends Collection<E>> |
collect(C collection)
Fill the given collection with all elements from this result set.
|
void |
each(Consumer<? super E> action)
Consume the results with the given
Consumer . |
E |
first()
Gets the first element of this result set.
|
E |
firstOr(E defaultElement)
Gets the first element or a default value.
|
E |
firstOr(Supplier<E> supplier)
Gets the first element or a default value from a
Supplier . |
E |
firstOrNull()
Gets the first element or a default null value.
|
CloseableIterator<E> |
iterator() |
CloseableIterator<E> |
iterator(int skip,
int take)
Creates a
AutoCloseable Iterator over a window of the elements
in this result. |
Stream<E> |
stream() |
List<E> |
toList()
Converts this result into a list.
|
<K> Map<K,E> |
toMap(Expression<K> key)
Map the results into a new map using an expression of the result element as a key.
|
<K> Map<K,E> |
toMap(Expression<K> key,
Map<K,E> map)
Map the results into the given map using an expression of the result element as a key.
|
forEach, spliterator
CloseableIterator<E> iterator()
iterator
in interface CloseableIterable<E>
iterator
in interface Iterable<E>
AutoCloseable
Iterator
over the elements in this result.CloseableIterator<E> iterator(int skip, int take)
AutoCloseable
Iterator
over a window of the elements
in this result.skip
- number of elements to skip overtake
- number of elements to receivevoid close()
close
in interface AutoCloseable
@CheckReturnValue Stream<E> stream()
Stream
instance over the result set. Java 8 only.<C extends Collection<E>> C collect(C collection)
C
- collection to fillcollection
- to fill@CheckReturnValue E first() throws NoSuchElementException
NoSuchElementException
- if there is no first element (empty result).@CheckReturnValue E firstOr(E defaultElement)
defaultElement
- default value for when there is no first element.@CheckReturnValue E firstOr(Supplier<E> supplier)
Supplier
.supplier
- value supplier for when there is no first element.@CheckReturnValue E firstOrNull()
void each(Consumer<? super E> action)
Consumer
. In Java 8 use Iterable.forEach(java.util.function.Consumer<? super T>)
instead.action
- to receive the elements in this result.@CheckReturnValue List<E> toList()
@CheckReturnValue <K> Map<K,E> toMap(Expression<K> key)
K
- type of keykey
- expression key, must be present in all result elements@CheckReturnValue <K> Map<K,E> toMap(Expression<K> key, Map<K,E> map)
K
- type of keykey
- expression key, must be present in all result elementsmap
- map instance to be populated