use of org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep in project janusgraph by JanusGraph.
the class HasStepFolder method foldInHasFilter.
/**
* Convert a TraversalFilterStep that is essentially "has(key)" into a normal HasStep
* @param traversal local traversal
* @param currentStep
*/
static Step foldInHasFilter(final Traversal.Admin<?, ?> traversal, final TraversalFilterStep<?> currentStep) {
List<? extends Traversal.Admin<?, ?>> traversals = currentStep.getLocalChildren();
assert (traversals.size() == 1);
List<Step> steps = traversals.get(0).getSteps();
assert (steps.size() == 1 && steps.get(0) instanceof PropertiesStep);
String[] propertyKeys = ((PropertiesStep) steps.get(0)).getPropertyKeys();
assert (propertyKeys.length == 1);
HasStep hasStep = new HasStep(traversal, new HasContainer(propertyKeys[0], P.neq(null)));
currentStep.getLabels().forEach(hasStep::addLabel);
TraversalHelper.replaceStep(currentStep, hasStep, traversal);
return hasStep;
}
Aggregations