Package org.apache.tinkerpop.gremlin.gql
Class PropertyPredicate
java.lang.Object
org.apache.tinkerpop.gremlin.gql.PropertyPredicate
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 bygetParamName().
Use ofLiteral(String, Object) and ofParam(String, String) to construct
instances. Use test(Element, Map) to evaluate the predicate during DFS execution.
-
Method Summary
Modifier and TypeMethodDescriptiongetKey()Returns the property key this predicate applies to.Returns the literal expected value, ornullif this is a parameter reference.Returns the parameter name (without$prefix), ornullif this is a literal predicate.booleanReturnstrueif this predicate resolves its value from the params map.static PropertyPredicateCreates a literal predicate:element.property(key) == value.static PropertyPredicateCreates a parameter-reference predicate: the expected value is resolved from the params map at execution time usingparamNameas the key.booleanEvaluates this predicate against the given element.toString()
-
Method Details
-
ofLiteral
Creates a literal predicate:element.property(key) == value.- Parameters:
key- the property keyvalue- the expected literal value (String, Long, Double, or Boolean)
-
ofParam
Creates a parameter-reference predicate: the expected value is resolved from the params map at execution time usingparamNameas the key.- Parameters:
key- the property keyparamName- the name of the parameter in the params map (without the$prefix)
-
test
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
paramsbygetParamName()(if this is a param predicate). A missing param key or a missing property both evaluate tonull; the predicate passes only if both sides are equal viaObjects.equals(java.lang.Object, java.lang.Object).- Parameters:
element- the graph element to testparams- the parameter bindings frommatch(String, Map); may be empty- Returns:
trueif any of the element's values for the key equal the expected value, or if the property is absent and the expected value isnull
-
getKey
Returns the property key this predicate applies to. -
getLiteralValue
Returns the literal expected value, ornullif this is a parameter reference. -
getParamName
Returns the parameter name (without$prefix), ornullif this is a literal predicate. -
isParamRef
public boolean isParamRef()Returnstrueif this predicate resolves its value from the params map. -
toString
-