Package se.l4.silo
Interface FetchResult<T>
-
- Type Parameters:
T-
- All Superinterfaces:
AutoCloseable,Iterable<T>
- All Known Subinterfaces:
QueryFetchResult<T>
- All Known Implementing Classes:
EmptyFetchResult,IteratorFetchResult,TransformingFetchResult,TransformingQueryFetchResult
public interface FetchResult<T> extends AutoCloseable, Iterable<T>
Result of a fetch request, contains the results and information about the parameters used for fetching.- Author:
- Andreas Holstenson
-
-
Method Summary
Modifier and Type Method Description voidclose()static <N> FetchResult<N>empty()Get an empty fetch result.default Optional<T>first()Get the first entry is this result.static <N> FetchResult<N>forCollection(Collection<N> collection)Get aFetchResultfor the given collection.static <N> FetchResult<N>forCollection(Collection<N> collection, int offset, int limit, int hits)Get aFetchResultfor the given collection.longgetLimit()Get the limit used to fetch these results.longgetOffset()Get the offset used to fetch these results.longgetSize()Get the number of returned results.longgetTotal()Get the total number of results available.booleanisEmpty()Check if these results are empty.default Stream<T>parallelStream()Get aStreamfor this result for parallel operations, seeCollection.parallelStream()for details.static <N> FetchResult<N>single(N data)Get aFetchResultrepresenting the fetch of a single item.default Spliterator<T>spliterator()default Stream<T>stream()Get aStreamfor this result, seeCollection.stream()for details.default <N> FetchResult<N>transform(Function<T,N> func)Transform this fetch result using the given function.
-
-
-
Method Detail
-
getSize
long getSize()
Get the number of returned results.- Returns:
-
getOffset
long getOffset()
Get the offset used to fetch these results.- Returns:
-
getLimit
long getLimit()
Get the limit used to fetch these results.- Returns:
-
getTotal
long getTotal()
Get the total number of results available.- Returns:
-
isEmpty
boolean isEmpty()
Check if these results are empty.- Returns:
-
close
void close()
- Specified by:
closein interfaceAutoCloseable
-
transform
default <N> FetchResult<N> transform(Function<T,N> func)
Transform this fetch result using the given function.- Parameters:
func-- Returns:
-
spliterator
default Spliterator<T> spliterator()
- Specified by:
spliteratorin interfaceIterable<T>
-
stream
default Stream<T> stream()
Get aStreamfor this result, seeCollection.stream()for details. The returned stream will close this result when it itself is closed.- Returns:
-
parallelStream
default Stream<T> parallelStream()
Get aStreamfor this result for parallel operations, seeCollection.parallelStream()for details. The returned stream will close this result when it itself is closed.- Returns:
-
empty
static <N> FetchResult<N> empty()
Get an empty fetch result.- Returns:
-
single
static <N> FetchResult<N> single(N data)
Get aFetchResultrepresenting the fetch of a single item.- Parameters:
data-- Returns:
-
forCollection
static <N> FetchResult<N> forCollection(Collection<N> collection)
Get aFetchResultfor the given collection. This will assume that the offset and limit used to fetch this was zero.- Parameters:
collection-- Returns:
-
forCollection
static <N> FetchResult<N> forCollection(Collection<N> collection, int offset, int limit, int hits)
Get aFetchResultfor the given collection. This will assume that the offset and limit used to fetch this was zero.- Parameters:
collection-- Returns:
-
-