Class MultiAttributeProjection<K,V,R>

java.lang.Object
com.loomcache.server.compute.MultiAttributeProjection<K,V,R>
Type Parameters:
K - the type of the key
V - the type of the value
R - the type of each attribute
All Implemented Interfaces:
Projection<K,V,List<R>>

public class MultiAttributeProjection<K,V,R> extends Object implements Projection<K,V,List<R>>
Built-in projection that extracts multiple attributes from values.

Returns an unmodifiable list of attributes extracted from each value.

Usage:

  MultiAttributeProjectioninvalid input: '<'String, Person, Object> multiProj =
      new MultiAttributeProjectioninvalid input: '<'>(
          Person::getName,
          Person::getAge,
          Person::getEmail
      );
  Listinvalid input: '<'List> rows = executor.project(multiProj);



  • Constructor Details

    • MultiAttributeProjection

      @SafeVarargs public MultiAttributeProjection(Function<V,R>... extractors)
      Create a new multi-attribute projection.
      Parameters:
      extractors - the functions to extract attributes from the value (must not be empty)
      Throws:
      IllegalArgumentException - if extractors is null or empty
  • Method Details

    • transform

      public List<R> transform(Map.Entry<K,V> entry)
      Description copied from interface: Projection
      Transform a map entry to the projected result.
      Specified by:
      transform in interface Projection<K,V,R>
      Parameters:
      entry - the detached, immutable entry snapshot to transform; the server provides a read-only snapshot, and direct callers must do the same because invoking Map.Entry.setValue(Object) never updates cache state and is unsupported
      Returns:
      the projected result