Package org.neo4j.graphdb.traversal
Class Evaluators
java.lang.Object
org.neo4j.graphdb.traversal.Evaluators
Common
Evaluator
s useful during common traversals.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <STATE> PathEvaluator<STATE>
all()
static <STATE> PathEvaluator<STATE>
atDepth
(int depth) Returns anEvaluator
which only includes positions atdepth
and prunes everything deeper than that.static <STATE> PathEvaluator<STATE>
endNodeIs
(Evaluation evaluationIfMatch, Evaluation evaluationIfNoMatch, Node... possibleEndNodes) AnEvaluator
which will returnevaluationIfMatch
ifPath.endNode()
for a given path is any ofnodes
, elseevaluationIfNoMatch
.static <STATE> PathEvaluator<STATE>
endNodeIsAtDepth
(int depth, Node... possibleEndNodes) ReturnsEvaluator
s for paths with the specified depth and with an end node from the list of possibleEndNodes.static PathEvaluator
static <STATE> PathEvaluator<STATE>
fromDepth
(int depth) Returns anEvaluator
which only includes positions fromdepth
and deeper and never prunes anything.static <STATE> PathEvaluator<STATE>
includeIfAcceptedByAny
(Evaluator... evaluators) Whereas addingEvaluator
s to aTraversalDescription
puts those evaluators inAND-mode
this can group many evaluators inOR-mode
.static <STATE> PathEvaluator<STATE>
includeIfAcceptedByAny
(PathEvaluator... evaluators) Whereas addingEvaluator
s to aTraversalDescription
puts those evaluators inAND-mode
this can group many evaluators inOR-mode
.static <STATE> PathEvaluator<STATE>
includeIfContainsAll
(Node... nodes) Evaluator which decides to include aPath
if all thenodes
exist in it.static <STATE> PathEvaluator<STATE>
includeWhereEndNodeIs
(Node... nodes) Include paths with the specified end nodes.static <STATE> PathEvaluator<STATE>
includeWhereLastRelationshipTypeIs
(RelationshipType type, RelationshipType... orAnyOfTheseTypes) static <STATE> PathEvaluator<STATE>
includingDepths
(int minDepth, int maxDepth) static <STATE> PathEvaluator<STATE>
lastRelationshipTypeIs
(Evaluation evaluationIfMatch, Evaluation evaluationIfNoMatch, RelationshipType type, RelationshipType... orAnyOfTheseTypes) static <STATE> PathEvaluator<STATE>
pruneWhereEndNodeIs
(Node... nodes) static <STATE> PathEvaluator<STATE>
pruneWhereLastRelationshipTypeIs
(RelationshipType type, RelationshipType... orAnyOfTheseTypes) static <STATE> PathEvaluator<STATE>
toDepth
(int depth) Returns anEvaluator
which includes positions down todepth
and prunes everything deeper than that.
-
Constructor Details
-
Evaluators
public Evaluators()
-
-
Method Details
-
all
- Type Parameters:
STATE
- the type of the state object.- Returns:
- an evaluator which includes everything it encounters and doesn't prune anything.
-
excludeStartPosition
- Returns:
- an evaluator which never prunes and includes everything except the first position, i.e. the the start node.
-
toDepth
Returns anEvaluator
which includes positions down todepth
and prunes everything deeper than that.- Type Parameters:
STATE
- the type of the state object.- Parameters:
depth
- the max depth to traverse to.- Returns:
- Returns an
Evaluator
which includes positions down todepth
and prunes everything deeper than that.
-
fromDepth
Returns anEvaluator
which only includes positions fromdepth
and deeper and never prunes anything.- Type Parameters:
STATE
- the type of the state object.- Parameters:
depth
- the depth to start include positions from.- Returns:
- Returns an
Evaluator
which only includes positions fromdepth
and deeper and never prunes anything.
-
atDepth
Returns anEvaluator
which only includes positions atdepth
and prunes everything deeper than that.- Type Parameters:
STATE
- the type of the state object.- Parameters:
depth
- the depth to start include positions from.- Returns:
- Returns an
Evaluator
which only includes positions atdepth
and prunes everything deeper than that.
-
includingDepths
Returns anEvaluator
which only includes positions between depthsminDepth
andmaxDepth
. It prunes everything deeper thanmaxDepth
.- Type Parameters:
STATE
- the type of the state object.- Parameters:
minDepth
- minimum depth a position must have to be included.maxDepth
- maximum depth a position must have to be included.- Returns:
- Returns an
Evaluator
which only includes positions between depthsminDepth
andmaxDepth
. It prunes everything deeper thanmaxDepth
.
-
lastRelationshipTypeIs
public static <STATE> PathEvaluator<STATE> lastRelationshipTypeIs(Evaluation evaluationIfMatch, Evaluation evaluationIfNoMatch, RelationshipType type, RelationshipType... orAnyOfTheseTypes) Returns anEvaluator
which compares the type of the last relationship in aPath
to a given set of relationship types (one or more).If the type of the last relationship in a path is of one of the given types thenevaluationIfMatch
will be returned, otherwiseevaluationIfNoMatch
will be returned.- Type Parameters:
STATE
- the type of the state object.- Parameters:
evaluationIfMatch
- theEvaluation
to return if the type of the last relationship in the path matches any of the given types.evaluationIfNoMatch
- theEvaluation
to return if the type of the last relationship in the path doesn't match any of the given types.type
- the (first) type (of possibly many) to match the last relationship in paths with.orAnyOfTheseTypes
- additional types to match the last relationship in paths with.- Returns:
- an
Evaluator
which compares the type of the last relationship in aPath
to a given set of relationship types.
-
includeWhereLastRelationshipTypeIs
public static <STATE> PathEvaluator<STATE> includeWhereLastRelationshipTypeIs(RelationshipType type, RelationshipType... orAnyOfTheseTypes) - Type Parameters:
STATE
- the type of the state object.- Parameters:
type
- the (first) type (of possibly many) to match the last relationship in paths with.orAnyOfTheseTypes
- types to match the last relationship in paths with. If any matches it's considered a match.- Returns:
- an
Evaluator
which compares the type of the last relationship in aPath
to a given set of relationship types. - See Also:
-
pruneWhereLastRelationshipTypeIs
public static <STATE> PathEvaluator<STATE> pruneWhereLastRelationshipTypeIs(RelationshipType type, RelationshipType... orAnyOfTheseTypes) - Type Parameters:
STATE
- the type of the state object.- Parameters:
type
- the (first) type (of possibly many) to match the last relationship in paths with.orAnyOfTheseTypes
- types to match the last relationship in paths with. If any matches it's considered a match.- Returns:
- an
Evaluator
which compares the type of the last relationship in aPath
to a given set of relationship types. - See Also:
-
endNodeIs
public static <STATE> PathEvaluator<STATE> endNodeIs(Evaluation evaluationIfMatch, Evaluation evaluationIfNoMatch, Node... possibleEndNodes) AnEvaluator
which will returnevaluationIfMatch
ifPath.endNode()
for a given path is any ofnodes
, elseevaluationIfNoMatch
.- Type Parameters:
STATE
- the type of the state object.- Parameters:
evaluationIfMatch
- theEvaluation
to return if thePath.endNode()
is any of the nodes innodes
.evaluationIfNoMatch
- theEvaluation
to return if thePath.endNode()
doesn't match any of the nodes innodes
.possibleEndNodes
- a set of nodes to match to end nodes in paths.- Returns:
- an
Evaluator
which will returnevaluationIfMatch
ifPath.endNode()
for a given path is any ofnodes
, elseevaluationIfNoMatch
.
-
includeWhereEndNodeIs
Include paths with the specified end nodes. Uses Evaluators#endNodeIs(Evaluation, Evaluation, Node...) withEvaluation.INCLUDE_AND_CONTINUE
forevaluationIfMatch
andEvaluation.EXCLUDE_AND_CONTINUE
forevaluationIfNoMatch
.- Type Parameters:
STATE
- the type of the state object.- Parameters:
nodes
- end nodes for paths to be included in the result.- Returns:
- paths where the end node is one of
nodes
-
pruneWhereEndNodeIs
-
includeIfContainsAll
Evaluator which decides to include aPath
if all thenodes
exist in it.- Type Parameters:
STATE
- the type of the state object.- Parameters:
nodes
-Node
s that must exist in aPath
for it to be included.- Returns:
Evaluation.INCLUDE_AND_CONTINUE
if allnodes
exist in a givenPath
, otherwiseEvaluation.EXCLUDE_AND_CONTINUE
.
-
includeIfAcceptedByAny
Whereas addingEvaluator
s to aTraversalDescription
puts those evaluators inAND-mode
this can group many evaluators inOR-mode
.- Type Parameters:
STATE
- the type of the state object.- Parameters:
evaluators
- represented as one evaluators. If any of the evaluators decides to include a path it will be included.- Returns:
- an
Evaluator
which decides to include a path if any of the supplied evaluators wants to include it.
-
includeIfAcceptedByAny
Whereas addingEvaluator
s to aTraversalDescription
puts those evaluators inAND-mode
this can group many evaluators inOR-mode
.- Type Parameters:
STATE
- the type of the state object.- Parameters:
evaluators
- represented as one evaluators. If any of the evaluators decides to include a path it will be included.- Returns:
- an
Evaluator
which decides to include a path if any of the supplied evaluators wants to include it.
-
endNodeIsAtDepth
ReturnsEvaluator
s for paths with the specified depth and with an end node from the list of possibleEndNodes.- Type Parameters:
STATE
- the type of the state object.- Parameters:
depth
- The exact depth to filter the returned path evaluators.possibleEndNodes
- Filter for the possible nodes to end the path on.- Returns:
Evaluator
s for paths with the specified depth and with an end node from the list of possibleEndNodes.
-