Class Search<A>

java.lang.Object
eu.bandm.tools.paisley.AbstractPattern<A>
eu.bandm.tools.paisley.Search<A>
Type Parameters:
A - the target type.
All Implemented Interfaces:
Pattern<A>, Serializable, Cloneable

@Generated(generator="eu.bandm.tools.expander", version="1.3.1", timestamp="2026-01-21T10:41:16") public abstract class Search<A> extends AbstractPattern<A>
Abstract base class for patterns that delegate matching dynamically to a number of alternative subpatterns.

Subclasses must implement the initAlternatives(A) and nextAlternative() methods.

See Also:
  • Field Details

    • currentAlt

      protected transient Pattern<? super A> currentAlt
      The current alternative.
    • currentAltTarget

      protected transient A currentAltTarget
      The target for the current alternative.
  • Constructor Details

    • Search

      protected Search()
      Creates a new instance.
  • Method Details

    • initAlternatives

      protected abstract void initAlternatives(A target)
      Sets up the dynamic enumeration of alternatives for a target.
      Parameters:
      target - the object to be matched against.
    • nextAlternative

      protected abstract boolean nextAlternative()
      Enumerates an alternative. Must be called only after initAlternatives(A).

      If an alternative is found, currentAlt and currentAltTarget must be set accordingly.

      Returns:
      true if an(other) alternative has been found; false otherwise.
    • 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 uses initAlternatives(A) and nextAlternative() to find the first matching alternative for the target, and succeeds if one is found. Alternative matching is done by alt.match(arg).

      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 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().

      This implementation first tries to match the last matching alternative again. On failure it uses nextAlternative() to find the next matching alternative for the target, and succeeds if one is found.

      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:
    • isDeterministic

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

      The default implementation returns false.

      This implementation returns false.

      Returns:
      true if this pattern is guaranteed to match any object at most once, false otherwise.
      See Also: