Schnittstelle Transformer<T extends @Nullable Object>

Typparameter:
T - The type of state to be transformed in a chain
Alle Superschnittstellen:
Function<T,T>
Funktionsschnittstelle:
Dies ist eine funktionale Schnittstelle, die somit als Zuweisungsziel für einen Lambdaausdruck oder eine Methodenreferenz verwendet werden kann.

@FunctionalInterface @API(status=EXPERIMENTAL, since="1.7.0") public interface Transformer<T extends @Nullable Object> extends Function<T,T>
A transformer is used to transform a state of type T into another value of this type. Transformation can create a new object, or change the inner state of an object and return it.

In addition to performing a state transformation the mutator function can also check or assert conditions and invariants that should hold when doing the transformation. This is especially useful when a transformer is used as part of an action.

Siehe auch:
  • Felddetails

    • END_OF_CHAIN

      static final Transformer<?> END_OF_CHAIN
      The singleton object used for all calls to endOfChain().
    • NOOP

      static final Transformer<?> NOOP
      The singleton object used for all calls to noop().
  • Methodendetails

    • endOfChain

      static <T extends @Nullable Object> Transformer<T> endOfChain()
      Use this transformer to stop further enhancement of a chain.

      Whenever a endOfChain() is chosen by a chain, the chain ends with the current state being provided (e.g. in the chain's iterator) for a last time.

      Typparameter:
      T - The transformer's state value type
      Gibt zurück:
      a transformer instance
    • noop

      static <T> Transformer<T> noop()
      Use this transformer to signal a noop transformation. This can be useful when a Transformation wants to provide a transformer that does nothing in some circumstances.

      Noop transformers are ignored and not added to the chain of transformers.

      Typparameter:
      T - The transformer's state value type
      Gibt zurück:
      a transformer instance
    • transform

      static <S extends @Nullable Object> Transformer<S> transform(String description, Function<? super S,? extends S> transform)
      Create a transformer with a description
      Typparameter:
      S - The type of the state to transform
      Parameter:
      description - A text to describe what the transform is doing
      transform - The actual transforming function
      Gibt zurück:
      a new instance of a transformer
    • mutate

      static <S extends @Nullable Object> Transformer<S> mutate(String description, Consumer<? super S> mutate)
      Convenience method to create a transformer with a description. A mutator works on a mutable, stateful object which will always be returned.
      Typparameter:
      S - The type of the state to mutate
      Parameter:
      description - A text to describe what the transform is doing
      mutate - The actual mutating operation
      Gibt zurück:
      a new instance of a transformer
    • transformation

      default String transformation()
      Describe the transformation this Transformer is doing in a human understandable way.
      Gibt zurück:
      non-empty String
    • isEndOfChain

      default boolean isEndOfChain()