@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");
             }
           });
 }
Beispiel #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) {

    }
  }
Beispiel #3
0
 public String toString() {
   return TraversalHelper.makeStepString(this, Arrays.asList(this.propertyKeys));
 }
Beispiel #4
0
 public default GraphTraversal<S, E> as(final String label) {
   TraversalHelper.verifyStepLabelIsNotAlreadyAStepLabel(label, this);
   TraversalHelper.verifyStepLabelIsNotASideEffectKey(label, this);
   TraversalHelper.getEnd(this).setLabel(label);
   return this;
 }
Beispiel #5
0
 public default <E2> GraphTraversal<S, E2> cap() {
   return this.cap(((SideEffectCapable) TraversalHelper.getEnd(this)).getSideEffectKey());
 }