Class TotalTransform<A,B>

Type Parameters:
A - the target type of the containing pattern
B - the target type of the contained subpattern
All Implemented Interfaces:
Pattern<A>, Serializable, Cloneable

@Generated(generator="eu.bandm.tools.expander", version="1.3.1", timestamp="2026-02-18T13:05:44") public abstract class TotalTransform<A,B> extends Transform<A,B>
Abstract base class for patterns that delegate transformed targets to a subpattern.

Subclasses must implement the Transform.apply(A) method.

See Also:
  • Constructor Details

    • TotalTransform

      protected TotalTransform(Pattern<? super B> body)
      Creates a new instance.
      Parameters:
      body - the subpattern
      Throws:
      NullPointerException - if body is null
  • Method Details

    • match

      public boolean match(A target)
      Attempts to match this pattern against a given object.

      If the class of this pattern imposes a specific order on matches, the first one is chosen.

      The null target is generally allowed.

      This implementation matches the subpattern against the result of apply(target).

      Parameters:
      target - the object to match against
      Returns:
      true if the matching is successful, false if it fails. Which Variables are bound by a successful or failed match depends.
      See Also:
    • of

      public static <A, B> TotalTransform<A,B> of(Function<? super A,? extends B> fun, Pattern<? super B> body)
      Returns a transforming pattern with the given transforming function and subpattern.
      Type Parameters:
      A - the target type of objects to match against
      B - the type of transformed objects
      Parameters:
      fun - a transforming function
      body - a subpattern to match the transformed targets against
      Returns:
      a pattern that matches body against each target transformed by fun
      Throws:
      NullPointerException - if fun or body is null
    • with

      public static <A, B> Motif<B,A> with(Function<? super A,? extends B> fun)
      Returns a motif that acts as a transforming pattern with the given transforming function and a hole in place of the subpattern.
      Type Parameters:
      A - the target type of objects to match against
      B - the type of transformed objects
      Parameters:
      fun - a transforming function
      Returns:
      a motif that matches the hole against each target transformed by fun
      Throws:
      NullPointerException - if fun is null