Class PropertyPredicate

java.lang.Object
org.apache.tinkerpop.gremlin.gql.PropertyPredicate

public final class PropertyPredicate extends Object
A single property equality predicate attached to a node pattern in a GQL MATCH clause.

A predicate is either:

  • Literal — the expected value is a compile-time constant (string, long, double, or boolean) parsed from the query string.
  • Parameter reference — the expected value is resolved at execution time from the params map passed to match(String, Map), keyed by getParamName().

Use ofLiteral(String, Object) and ofParam(String, String) to construct instances. Use test(Element, Map) to evaluate the predicate during DFS execution.

  • Method Details

    • ofLiteral

      public static PropertyPredicate ofLiteral(String key, Object value)
      Creates a literal predicate: element.property(key) == value.
      Parameters:
      key - the property key
      value - the expected literal value (String, Long, Double, or Boolean)
    • ofParam

      public static PropertyPredicate ofParam(String key, String paramName)
      Creates a parameter-reference predicate: the expected value is resolved from the params map at execution time using paramName as the key.
      Parameters:
      key - the property key
      paramName - the name of the parameter in the params map (without the $ prefix)
    • test

      public boolean test(Element element, Map<String,Object> params)
      Evaluates this predicate against the given element.

      The expected value is the literal (if this is a literal predicate) or the value looked up from params by getParamName() (if this is a param predicate). A missing param key or a missing property both evaluate to null; the predicate passes only if both sides are equal via Objects.equals(java.lang.Object, java.lang.Object).

      Parameters:
      element - the graph element to test
      params - the parameter bindings from match(String, Map); may be empty
      Returns:
      true if any of the element's values for the key equal the expected value, or if the property is absent and the expected value is null
    • getKey

      public String getKey()
      Returns the property key this predicate applies to.
    • getLiteralValue

      public Object getLiteralValue()
      Returns the literal expected value, or null if this is a parameter reference.
    • getParamName

      public String getParamName()
      Returns the parameter name (without $ prefix), or null if this is a literal predicate.
    • isParamRef

      public boolean isParamRef()
      Returns true if this predicate resolves its value from the params map.
    • toString

      public String toString()
      Overrides:
      toString in class Object