Interface StaticContextCalculator

All Superinterfaces:
ContextCalculator<Object>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StaticContextCalculator extends ContextCalculator<Object>
Extension of ContextCalculator which provides the same context regardless of the subject.
  • Method Details

    • forSingleContext

      static StaticContextCalculator forSingleContext(String key, Supplier<String> valueFunction)
      Creates a new StaticContextCalculator that provides a single context.
      Parameters:
      key - the key of the context provided by the calculator
      valueFunction - the function used to compute the corresponding value for each query. A context will not be "accumulated" if the value returned is null.
      Returns:
      the resultant calculator
    • calculate

      void calculate(@NonNull ContextConsumer consumer)
      Submits any contexts this calculator determines to be applicable.

      Care should be taken to ensure implementations of this method meet the general requirements for ContextCalculator, defined in the class doc.

      Parameters:
      consumer - the ContextConsumer to submit contexts to
    • calculate

      default void calculate(@NonNull Object target, @NonNull ContextConsumer consumer)
      Description copied from interface: ContextCalculator
      Submits any contexts this calculator determines to be applicable to the target contextual subject.

      Care should be taken to ensure implementations of this method meet the general requirements for ContextCalculator, defined in the class doc.

      Specified by:
      calculate in interface ContextCalculator<Object>
      Parameters:
      target - the target contextual subject for this operation
      consumer - the ContextConsumer to submit contexts to