Esempio n. 1
0
 public ChooseStep(
     final Traversal traversal,
     final SPredicate<Traverser<S>> ifPredicate,
     final Traversal<S, E> trueBranch,
     final Traversal<S, E> falseBranch) {
   super(traversal);
   this.setFunction(
       traverser -> {
         final Traversal<S, E> branch = ifPredicate.test(traverser) ? trueBranch : falseBranch;
         branch.addStarts(new SingleIterator<>(traverser));
         return branch;
       });
 }
Esempio n. 2
0
 public ChooseStep(
     final Traversal traversal,
     final SFunction<Traverser<S>, M> mapFunction,
     final Map<M, Traversal<S, E>> branches) {
   super(traversal);
   this.setFunction(
       traverser -> {
         final Traversal<S, E> branch = branches.get(mapFunction.apply(traverser));
         if (null == branch) {
           return Collections.emptyIterator();
         } else {
           branch.addStarts(new SingleIterator<>(traverser));
           return branch;
         }
       });
 }