Interface ProjectionCompositor<E,V>
- Type Parameters:
E- The type of the temporary storage for component values.V- The type of the final result representing a composed value.
public interface ProjectionCompositor<E,V>
A variation on
Collector suitable for composing the result of inner projections
in a composite projection.
Compared to Collector:
- There is no concept of parallel execution.
- All operations are expected to be non-blocking,
except for
finish(Object) - The number of component values is known in advance,
and clients are expected to
setexactly that number of values every time. - The type of component values is flexible and the values can be mutated before they are composed,
but each component values is expected to have a specific type upon calling
finish(Object). Clients are responsible for ensuring component values have the required type upon callingfinish(Object).
-
Method Summary
Modifier and TypeMethodDescriptionCreates the initial container for component values.Finishes composition, converting the component container into the final result.static <P1,P2, V>
ProjectionCompositor<Object[], V> from(BiFunction<P1, P2, V> transformer) static <P1,V> ProjectionCompositor <Object, V> static <P1,P2, P3, V>
ProjectionCompositor<Object[], V> from(TriFunction<P1, P2, P3, V> transformer) static ProjectionCompositor<Object[], Object[]> fromArray(int size) static <V> ProjectionCompositor<Object[], V> static ProjectionCompositor<Object[], List<?>> fromList(int size) static <V> ProjectionCompositor<Object[], V> Gets a value from the given component container.Sets a value in the given component container.
-
Method Details
-
createInitial
E createInitial()Creates the initial container for component values.This operation should be non-blocking.
- Returns:
- The initial container for component values,
to pass to the first call to
set(Object, int, Object).
-
set
Sets a value in the given component container.This operation should be non-blocking.
- Parameters:
components- The container for component values collected so far. For the first call, this is the container returned bycreateInitial(). For the next calls, this is the container returned by the previous call toset(Object, int, Object).index- The index of the value to set.value- The value to set.- Returns:
- The container for component values.
-
get
Gets a value from the given component container.This operation should be non-blocking.
- Parameters:
components- The container for component values collected so far. This is the container returned by the last call toset(Object, int, Object).index- The index of the value to get.- Returns:
- The new container for component values.
-
finish
Finishes composition, converting the component container into the final result.This operation may be blocking.
- Parameters:
components- The container for component values created bycreateInitial()and populated by successive calls toset(Object, int, Object).- Returns:
- The final result of the collecting.
-
from
-
from
-
from
-
fromList
-
fromList
static <V> ProjectionCompositor<Object[],V> fromList(int size, Function<? super List<?>, ? extends V> transformer) -
fromArray
-
fromArray
static <V> ProjectionCompositor<Object[],V> fromArray(int size, Function<? super Object[], ? extends V> transformer)
-