Interface ProjectionAccumulator<F,V,U,R>
-
- Type Parameters:
F
- The type of (unconverted) field values.V
- The type of field values after the projection converter was applied.U
- The type of the temporary storage for collected field values of typeF
.R
- The type of the final result containing values of typeV
.
- All Known Implementing Classes:
ListProjectionAccumulator
,SingleValuedProjectionAccumulator
public interface ProjectionAccumulator<F,V,U,R>
A variation onCollector
suitable for projections on field values.Compared to
Collector
:- There is no concept of parallel execution.
- All operations are expected to be non-blocking,
except for
finish(Object, ProjectionConverter, FromDocumentFieldValueConvertContext)
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ProjectionAccumulator.Provider<V,R>
Provides an accumulator for a given underlying field type (F
).
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description U
accumulate(U accumulated, F value)
Folds a new value in the given accumulated container.U
createInitial()
Creates the initial accumulated container.R
finish(U accumulated, ProjectionConverter<? super F,? extends V> converter, FromDocumentFieldValueConvertContext context)
Finishes the collecting, converting the accumulated container into the final result.
-
-
-
Method Detail
-
createInitial
U createInitial()
Creates the initial accumulated container.This operation should be non-blocking.
- Returns:
- The initial accumulated container,
to pass to the first call to
accumulate(Object, Object)
.
-
accumulate
U accumulate(U accumulated, F value)
Folds a new value in the given accumulated container.This operation should be non-blocking.
- Parameters:
accumulated
- The accumulated value so far. For the first call, this is a value returned bycreateInitial()
. For the next calls, this is the value returned by the previous call toaccumulate(Object, Object)
.value
- The value to accumulate.- Returns:
- The new accumulated value.
-
finish
R finish(U accumulated, ProjectionConverter<? super F,? extends V> converter, FromDocumentFieldValueConvertContext context)
Finishes the collecting, converting the accumulated container into the final result.This operation may be blocking.
- Parameters:
accumulated
- The temporary storage created bycreateInitial()
and populated by successive calls toaccumulate(Object, Object)
.converter
- The projection converter (fromF
toV
).context
- The context to be passed to the projection converter.- Returns:
- The final result of the collecting.
-
-