Class SingleAttributeProjection<K,V,R>

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

public class SingleAttributeProjection<K,V,R> extends Object implements Projection<K,V,R>
Built-in projection that extracts a single attribute from values using a function.

Usage:

  Projectioninvalid input: '<'String, Person, String> nameProj =
      new SingleAttributeProjectioninvalid input: '<'>(Person::getName);
  List names = executor.project(nameProj);
  • Constructor Details

    • SingleAttributeProjection

      public SingleAttributeProjection(Function<V,R> extractor)
      Create a new single attribute projection.
      Parameters:
      extractor - the function to extract the attribute from the value (must not be null)
      Throws:
      NullPointerException - if extractor is null
  • Method Details

    • transform

      public 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