Class ComparisonPredicates

java.lang.Object
org.apache.sling.resource.filter.impl.predicates.ComparisonPredicates

public class ComparisonPredicates extends Object
Predicates to handle comparisons that are defined in the filter language
  • Constructor Details

    • ComparisonPredicates

      public ComparisonPredicates()
  • Method Details

    • is

      public static Predicate<Resource> is(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to Strings.
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if right hand String is equal to left hand String
    • isNot

      public static Predicate<Resource> isNot(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to Strings.
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if right hand String is equal to left hand String
    • like

      public static Predicate<Resource> like(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to Strings. Right hand value is treated as a Regular expression.
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if right hand value pattern matches the left hand value
    • gt

      public static Predicate<Resource> gt(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to a Number, and then additionally converted to a common type as the basis of comparison
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if left hand value is greater than right hand value
    • gte

      public static Predicate<Resource> gte(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to a Number, and then additionally converted to a common type as the basis of comparison
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if left hand value is greater than or equal to right hand value
    • lt

      public static Predicate<Resource> lt(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to a Number, and then additionally converted to a common type as the basis of comparison
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if left hand value is less than right hand value
    • lte

      public static Predicate<Resource> lte(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Values are converted to a Number, and then additionally converted to a common type as the basis of comparison
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if left hand value is less than or equal to right hand value
    • contains

      public static Predicate<Resource> contains(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Right and Left values are converted to String arrays
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if left hand values are a subset of right hand values
    • containsAny

      public static Predicate<Resource> containsAny(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Right and Left values are converted to String arrays
      Parameters:
      lhs - Function which provides comparison value
      rhs - Function which provides comparison value
      Returns:
      true if the left hand values matches any of the right hand values
    • in

      public static Predicate<Resource> in(Function<Resource,Object> lhs, Function<Resource,Object> rhs)
      Right and Left values are converted to String arrays
      Parameters:
      lhs - Function which provides value for comparison
      rhs - Function which provides value for comparison
      Returns:
      true if left hand values are a subset of right hand values