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 onCollectorsuitable 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
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description EcreateInitial()Creates the initial container for component values.Vfinish(E components)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>from(Function<P1,V> transformer)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>fromArray(int size, Function<? super Object[],? extends V> transformer)static ProjectionCompositor<Object[],List<?>>fromList(int size)static <V> ProjectionCompositor<Object[],V>fromList(int size, Function<? super List<?>,? extends V> transformer)Objectget(E components, int index)Gets a value from the given component container.Eset(E components, int index, Object value)Sets a value in the given component container.
-
-
-
Method Detail
-
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
E set(E components, int index, Object value)
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
Object get(E components, int index)
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
V finish(E components)
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
static <P1,V> ProjectionCompositor<Object,V> from(Function<P1,V> transformer)
-
from
static <P1,P2,V> ProjectionCompositor<Object[],V> from(BiFunction<P1,P2,V> transformer)
-
from
static <P1,P2,P3,V> ProjectionCompositor<Object[],V> from(TriFunction<P1,P2,P3,V> transformer)
-
fromList
static ProjectionCompositor<Object[],List<?>> fromList(int size)
-
fromList
static <V> ProjectionCompositor<Object[],V> fromList(int size, Function<? super List<?>,? extends V> transformer)
-
fromArray
static ProjectionCompositor<Object[],Object[]> fromArray(int size)
-
fromArray
static <V> ProjectionCompositor<Object[],V> fromArray(int size, Function<? super Object[],? extends V> transformer)
-
-