Class Constraint

All Implemented Interfaces:
Pattern<Object>, Serializable, Cloneable

@Generated(generator="eu.bandm.tools.expander", version="", timestamp="2026-01-24T11:39:11") public abstract class Constraint extends Atomic<Object>
Base class of deterministic patterns that do not examine the target object.

A pattern of this class can either succeed once or fail, determined by external information that does not depend on a given specific target.

See Also:
  • Constructor Details

    • Constraint

      public Constraint()
      Creates a new instance.
  • Method Details

    • match

      public boolean match(Object 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 ignores target and delegates to test().

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

      protected abstract boolean test()
      Checks whether this pattern should succeed or fail.
      Returns:
      true if this pattern should succeed once; false otherwise
    • of

      public static Constraint of(boolean constant)
      Returns a constraint that always succeeds or always fails.
      Parameters:
      constant - whether the constraint should succeed
      Returns:
      a constraint that matches a given target if and only if constant is true
    • of

      public static Constraint of(BooleanSupplier supplier)
      Returns a constraint that delegates to a given supplier.
      Parameters:
      supplier - the supplier to delegate to
      Returns:
      a constraint that matches a given target if and only if supplier returns true
      Throws:
      NullPointerException - if supplier is null
    • all

      public static Constraint all(Constraint... cs)
      Combines several constraints conjunctively.

      The combination behaves like the operator &&; if any constraint returns false, the subsequent ones are not evaluated at all.

      Parameters:
      cs - the constraints to combine
      Returns:
      a constraint that matches all given constraints in order, and succeeds if they all do
      Throws:
      NullPointerException - if cs is or contains null
    • all

      public static Constraint all(List<? extends Constraint> cs)
      Combines several constraints conjunctively.

      The combination behaves like the operator &&; if any constraint returns false, the subsequent ones are not evaluated at all.

      The given list of constraints is copied by this method; subsequent changes to the given list have no effect on the returned constraint.

      Parameters:
      cs - the constraints to combine
      Returns:
      a constraint that matches all given constraints in order, and succeeds if they all do
      Throws:
      NullPointerException - if cs is or contains null
    • some

      public static Constraint some(Constraint... cs)
      Combines several constraints disjunctively.

      The combination behaves like the operator ||; if any constraint returns true, the subsequent ones are not evaluated at all.

      Parameters:
      cs - the constraints to combine
      Returns:
      a constraint that matches all given constraints in order, and succeeds if any of them does
      Throws:
      NullPointerException - if cs is or contains null
    • some

      public static Constraint some(List<? extends Constraint> cs)
      Combines several constraints disjunctively.

      The combination behaves like the operator ||; if any constraint returns true, the subsequent ones are not evaluated at all.

      The given list of constraints is copied by this method; subsequent changes to the given list have no effect on the returned constraint.

      Parameters:
      cs - the constraints to combine
      Returns:
      a constraint that matches all given constraints in order, and succeeds if any of them does
      Throws:
      NullPointerException - if cs is or contains null