Class TupleQueryResultConverter
java.lang.Object
org.eclipse.rdf4j.spring.dao.support.operation.TupleQueryResultConverter
- Since:
- 4.0.0
- Author:
- Florian Kleedorfer
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<T> T
applyToResult
(Function<TupleQueryResult, T> function) Applies the function to theTupleQueryResult
and closes the result afterwards.void
consumeResult
(Consumer<TupleQueryResult> consumer) Passes theTupleQueryResult
to the consumer and closes the result afterwards.getBindingStream
(TupleQueryResult result) If the result has only one empty binding set, this method returns an empty stream, otherwise the stream of BindingSets<T,
A, R> R mapAndCollect
(Function<BindingSet, T> mapper, Collector<T, A, R> collector) <T> List<T>
toList
(BindingSetMapper<T> mapper) Maps the query result to aList
.<T,
O> List<O> toList
(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Maps the query result to aList
.<K,
V> Map<K, V> toMap
(Function<BindingSet, Map.Entry<K, V>> entryMapper) Maps the query result to aMap
, throwing an Exception if there are multiple values for one key.<K,
V> Map<K, V> toMap
(Function<BindingSet, K> keyMapper, Function<BindingSet, V> valueMapper) Maps the query result to aMap
, throwing an Exception if there are multiple values for one key.<T,
K, V> Map<K, V> toMap
(BindingSetMapper<T> mapper, Function<T, K> keyMapper, Function<T, V> valueMapper) Maps the query result to aMap
, throwing an Exception if there are multiple values for one key.toMapOfList
(Function<BindingSet, K> keyMapper, Function<BindingSet, V> valueMapper) toMapOfList
(BindingSetMapper<T> mapper, Function<T, K> keyMapper, Function<T, V> valueMapper) toMapOfSet
(Function<BindingSet, K> keyMapper, Function<BindingSet, V> valueMapper) toMapOfSet
(BindingSetMapper<T> mapper, Function<T, K> keyMapper, Function<T, V> valueMapper) <T> Set<T>
toSet
(BindingSetMapper<T> mapper) Maps the query result to aSet
.<T,
O> Set<O> toSet
(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Maps the query result to aSet
.<T> T
toSingleton
(BindingSetMapper<T> mapper) Maps the firstBindingSet
in the result, throwing an exception if there are no results or more than one.<T,
O> O toSingleton
(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Maps the firstBindingSet
in the result, throwing an exception if there are no results or more than one.<T> T
toSingletonMaybe
(BindingSetMapper<T> mapper) Maps the firstBindingSet
in the result if one exists, throwing an exception if there are more.<T,
O> O toSingletonMaybe
(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Maps the firstBindingSet
in the result if one exists, throwing an exception if there are more.<T> T
Maps the wholeTupleQueryResult
to one object, which may be null.<T> T
toSingletonOfWholeResult
(TupleQueryResultMapper<T> mapper) Maps the wholeTupleQueryResult
to an object, throwing an exception if the mapper returnsnull
.<T> Optional<T>
toSingletonOptional
(BindingSetMapper<T> mapper) Maps the firstBindingSet
in the result, throwing an exception if there are more than one.<T,
O> Optional<O> toSingletonOptional
(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) <T> Optional<T>
Maps the wholeTupleQueryResult
to oneOptional
.toStream()
Obtains a stream ofBindingSet
s.<T> Stream<T>
toStream
(BindingSetMapper<T> mapper) Obtains aStream
of mapped query results.<T,
O> Stream<O> toStream
(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Obtains aStream
of mapped query results, using the postprocessor to map it again.
-
Constructor Details
-
TupleQueryResultConverter
-
-
Method Details
-
consumeResult
Passes theTupleQueryResult
to the consumer and closes the result afterwards. -
applyToResult
Applies the function to theTupleQueryResult
and closes the result afterwards. -
toStream
Obtains a stream ofBindingSet
s. The result is completely consumed and closed when the stream is returned. -
toStream
Obtains aStream
of mapped query results. The result is completely consumed and closed when the stream is returned. Any null values are filterd from the resulting stream. -
toStream
public <T,O> Stream<O> toStream(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Obtains aStream
of mapped query results, using the postprocessor to map it again. Any null values are filtered from the resulting stream. -
toSingletonMaybeOfWholeResult
Maps the wholeTupleQueryResult
to one object, which may be null. -
toSingletonOptionalOfWholeResult
Maps the wholeTupleQueryResult
to oneOptional
. -
toSingletonOfWholeResult
Maps the wholeTupleQueryResult
to an object, throwing an exception if the mapper returnsnull
.- Throws:
IncorrectResultSetSizeException
-
toSingletonMaybe
Maps the firstBindingSet
in the result if one exists, throwing an exception if there are more. Returns null if there are no results or if there is one result that is mapped to null by the specified mapper.- Throws:
IncorrectResultSetSizeException
-
toSingletonOptional
Maps the firstBindingSet
in the result, throwing an exception if there are more than one. Returns an Optional, which is empty if there are no results or if there is one result that is mapped to null by the specified mapper. -
toSingleton
Maps the firstBindingSet
in the result, throwing an exception if there are no results or more than one.- Throws:
IncorrectResultSetSizeException
-
toSingletonMaybe
public <T,O> O toSingletonMaybe(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) Maps the firstBindingSet
in the result if one exists, throwing an exception if there are more.- Throws:
IncorrectResultSetSizeException
-
toSingletonOptional
public <T,O> Optional<O> toSingletonOptional(BindingSetMapper<T> mapper, MappingPostProcessor<T, O> postProcessor) -
toSingleton
Maps the firstBindingSet
in the result, throwing an exception if there are no results or more than one.- Throws:
IncorrectResultSetSizeException
-
mapAndCollect
-
toList
Maps the query result to aList
. -
toList
Maps the query result to aList
. -
toSet
Maps the query result to aSet
. -
toSet
Maps the query result to aSet
. -
toMap
Maps the query result to aMap
, throwing an Exception if there are multiple values for one key. -
toMapOfSet
public <K,V> Map<K,Set<V>> toMapOfSet(Function<BindingSet, K> keyMapper, Function<BindingSet, V> valueMapper) -
toMapOfList
public <K,V> Map<K,List<V>> toMapOfList(Function<BindingSet, K> keyMapper, Function<BindingSet, V> valueMapper) -
toMap
public <T,K, Map<K,V> V> toMap(BindingSetMapper<T> mapper, Function<T, K> keyMapper, Function<T, V> valueMapper) Maps the query result to aMap
, throwing an Exception if there are multiple values for one key. -
toMap
Maps the query result to aMap
, throwing an Exception if there are multiple values for one key. -
toMapOfSet
public <T,K, Map<K,V> Set<V>> toMapOfSet(BindingSetMapper<T> mapper, Function<T, K> keyMapper, Function<T, V> valueMapper) -
toMapOfList
public <T,K, Map<K,V> List<V>> toMapOfList(BindingSetMapper<T> mapper, Function<T, K> keyMapper, Function<T, V> valueMapper) -
getBindingStream
If the result has only one empty binding set, this method returns an empty stream, otherwise the stream of BindingSets
-