Interface QueryResultConverter<T,R>
- Type Parameters:
T- object type accepted by this converter.R- the returned result type.
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Converter for MongoDB query results.
This is a functional interface that allows for mapping a Document to a result type.
row mapping can obtain upstream a
upstream converter to enrich the final result object. This is useful when e.g.
wrapping result objects where the wrapper needs to obtain information from the actual Document.
- Since:
- 5.0
- Author:
- Mark Paluch
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA supplier that converts aDocumentintoT. -
Method Summary
Modifier and TypeMethodDescriptiondefault <V> QueryResultConverter<T, V> andThen(QueryResultConverter<? super R, ? extends V> after) Returns a composed function that first applies this function to its input, and then applies theafterfunction to the result.static <T> QueryResultConverter<T, T> entity()Returns a function that returns the materialized entity.mapDocument(org.bson.Document document, QueryResultConverter.ConversionResultSupplier<T> reader) Map aDocumentthat is read from the MongoDB query/aggregation operation to a query result.
-
Method Details
-
entity
Returns a function that returns the materialized entity.- Type Parameters:
T- the type of the input and output entity to the function.- Returns:
- a function that returns the materialized entity.
-
mapDocument
Map aDocumentthat is read from the MongoDB query/aggregation operation to a query result.- Parameters:
document- the raw document from the MongoDB query/aggregation result.reader- reader object that supplies an upstream result from an earlier converter.- Returns:
- the mapped result.
-
andThen
Returns a composed function that first applies this function to its input, and then applies theafterfunction to the result. If evaluation of either function throws an exception, it is relayed to the caller of the composed function.- Type Parameters:
V- the type of output of theafterfunction, and of the composed function.- Parameters:
after- the function to apply after this function is applied.- Returns:
- a composed function that first applies this function and then applies the
afterfunction.
-