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.

@FunctionalInterface public interface QueryResultConverter<T,R>
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
  • Method Details

    • entity

      static <T> QueryResultConverter<T,T> 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

      R mapDocument(org.bson.Document document, QueryResultConverter.ConversionResultSupplier<T> reader)
      Map a Document that 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

      default <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 the after function 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 the after function, 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 after function.