Ejemplo n.º 1
0
 @Override
 public void apply(final Traversal<?, ?> traversal, final TraversalEngine engine) {
   TraversalHelper.getStepsOfClass(LocalRangeStep.class, traversal)
       .forEach(
           localRangeStep -> {
             Step previousStep = localRangeStep.getPreviousStep();
             while (!previousStep.equals(EmptyStep.instance())
                 && !(previousStep instanceof PropertiesStep)
                 && !(previousStep instanceof VertexStep)) {
               previousStep = previousStep.getPreviousStep();
               // TODO: check for not filtering/sideEffect steps and throw an exception?
             }
             if (previousStep instanceof VertexStep) {
               VertexStep vertexStep = (VertexStep) previousStep;
               if (vertexStep.getReturnClass().equals(Edge.class)) {
                 localRangeStep.setDirection(vertexStep.getDirection());
               } else {
                 throw new IllegalStateException(
                     "LocalRangeStep must follow a VertexStep that produces edges, not vertices");
               }
             } else if (previousStep instanceof PropertiesStep) {
               // do nothing, all is good
             } else {
               throw new IllegalStateException(
                   "LocalRangeStep must follow a VertexStep or PropertiesStep");
             }
           });
 }
Ejemplo n.º 2
0
  @Override
  public default void remove() {
    try {
      this.applyStrategies(TraversalEngine.STANDARD);
      final Step<?, E> endStep = TraversalHelper.getEnd(this);
      while (true) {
        final Object object = endStep.next().get();
        if (object instanceof Element) ((Element) object).remove();
        else if (object instanceof Property) ((Property) object).remove();
        else {
          throw new IllegalStateException(
              "The following object does not have a remove() method: " + object);
        }
      }
    } catch (final NoSuchElementException ignored) {

    }
  }
Ejemplo n.º 3
0
 public <S> Traverser.Admin<S> generate(final S start, final Step<?, S> startStep) {
   return new PathTraverser<>(startStep.getLabel(), start, startStep.getTraversal().sideEffects());
 }