Class AnyConstraint

java.lang.Object
io.fluxcapacitor.common.api.search.constraints.AnyConstraint
All Implemented Interfaces:
Constraint

public class AnyConstraint extends Object implements Constraint
A composite constraint that requires at least one inner constraint to match.

This is equivalent to a logical OR operation over the contained constraints. The document matches if any of the provided constraints evaluate to true.

If the constraint list is empty, a NoOpConstraint is returned (which always matches). If only one constraint is provided, it is returned directly without wrapping in an AnyConstraint.

See Also:
  • Constructor Details

    • AnyConstraint

      public AnyConstraint()
  • Method Details

    • any

      public static Constraint any(Constraint... constraints)
      Creates an AnyConstraint from the given array of constraints.

      If the array is empty, a NoOpConstraint is returned. If only one constraint is provided, that constraint is returned directly.

      Parameters:
      constraints - one or more constraints to combine
      Returns:
      a constraint that matches if any input matches
    • any

      public static Constraint any(Collection<Constraint> constraints)
      Creates an AnyConstraint from the given collection of constraints.

      If the collection is empty, a NoOpConstraint is returned. If it contains only one constraint, that constraint is returned directly.

      Parameters:
      constraints - a collection of constraints to combine
      Returns:
      a constraint that matches if any input matches
    • matches

      public boolean matches(Document document)
      Description copied from interface: Constraint
      Evaluates whether this constraint applies to the given document.
      Specified by:
      matches in interface Constraint
      Parameters:
      document - the document to test
      Returns:
      true if the constraint matches the document
    • hasPathConstraint

      public boolean hasPathConstraint()
      Description copied from interface: Constraint
      Indicates whether this constraint targets specific paths in the document.
      Specified by:
      hasPathConstraint in interface Constraint
      Returns:
      true if path-based filtering is involved