Class FlatMultiTransform<A,B>

java.lang.Object
eu.bandm.tools.paisley.AbstractPattern<A>
eu.bandm.tools.paisley.Unary<B,A>
eu.bandm.tools.paisley.FlatMultiTransform<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, Iterator<B>
Direct Known Subclasses:
MultiTransform

@Generated(generator="eu.bandm.tools.expander", version="", timestamp="2026-01-24T11:39:14") public abstract class FlatMultiTransform<A,B> extends Unary<B,A> implements Iterator<B>
Abstract base class for patterns that delegate several transformation results for a target to a subpattern.

Matchings of the subpattern to the transformation results are combined disjunctively. In particular, matching fails altogether if there the number of transformation results is zero.

Transformation results for a target are iterated lazily on demand.

Subclasses should implement the methods open(A), close(), and must implement the methods Iterator.hasNext() and Iterator.next().

See Also:
  • Constructor Details

    • FlatMultiTransform

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

    • match

      public final 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.

      Specified by:
      match in interface Pattern<A>
      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:
    • matchAgain

      public final boolean matchAgain()
      Attempts to re-match this pattern against a previously matched object.

      If the class of this pattern imposes a specific order on matches, they are chosen in that order, beginning with the second one. The behaviour of this method is unspecified if the last matching attempt of this pattern has not been successful.

      Patterns classes that do not override this method are deterministic. Pattern classes that overwrite this method to provide additional matches should also override Pattern.isDeterministic(). The default implementation delegates to Unary.body.

      Specified by:
      matchAgain in interface Pattern<A>
      Overrides:
      matchAgain in class Unary<B,A>
      Returns:
      true if the matching is successful, false if it fails. Which Variables are bound by a successful match depends. The default implementation always returns false.
      See Also:
    • cut

      public final void cut(boolean recursively)
      Disposes of all temporary internal state related to nondeterminism.

      The default implementation does nothing. Subclasses that override this method should also override Pattern.clear(boolean) and ensure that it implies the effect of cut(false). The default implementation delegates to Unary.body if recursively is true.

      This implmentation calls close().

      Specified by:
      cut in interface Pattern<A>
      Overrides:
      cut in class Unary<B,A>
      Parameters:
      recursively - true if all subpatterns should traversed, false otherwise.
    • isDeterministic

      public final boolean isDeterministic()
      Checks whether this pattern is deterministic.

      The default implementation returns false. This implementation delegates to Unary.body.

      This implmentation always returns false.

      Specified by:
      isDeterministic in interface Pattern<A>
      Overrides:
      isDeterministic in class Unary<B,A>
      Returns:
      true if this pattern is guaranteed to match any object at most once, false otherwise.
      See Also:
    • open

      protected void open(A target)
      Initiates the iteration of transformation results for the given target.

      This method is called once for each invocation of match(A).

      The default implementation does nothing.

      Subclasses must implement this method to set up the initial iterator state.

      Parameters:
      target - the target object to match against
    • close

      protected void close()
      Finalizes the iteration of transformation results for the current target.

      This method is called once for each unsuccessful match, or for each invocation of cut(boolean).

      The default implementation does nothing.

      Subclasses should override this method to release resources needed during iteration. Implementations should be idempotent; immediately repeated calls should not result in further changes.