Class NotConstraint

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

public class NotConstraint extends Object implements Constraint
A constraint that negates the result of another constraint.

This is equivalent to a logical NOT. A document matches this constraint if it does not match the provided inner constraint.

Example: to find all documents that do not have a particular value:


 Constraint notAdmin = NotConstraint.not(MatchConstraint.match("admin", "userRole"));
 
See Also:
  • Constructor Details

    • NotConstraint

      public NotConstraint()
  • Method Details

    • not

      public static NotConstraint not(Constraint constraint)
      Factory method to create a NotConstraint.
      Parameters:
      constraint - the constraint to negate
      Returns:
      a constraint that matches if the input constraint does not match
    • 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