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 set exactly 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 calling finish(Object).
  • 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

      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 by createInitial(). For the next calls, this is the container returned by the previous call to set(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 to set(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 by createInitial() and populated by successive calls to set(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)