コード例 #1
0
 /**
  * Determine if the traversal has a step of an assignable class.
  *
  * @param superClass the step super class to look for
  * @param traversal the traversal to perform the action on
  * @return {@code true} if the class is found and {@code false} otherwise
  */
 public static boolean hasStepOfAssignableClass(
     final Class superClass, final Traversal.Admin<?, ?> traversal) {
   for (final Step<?, ?> step : traversal.getSteps()) {
     if (superClass.isAssignableFrom(step.getClass())) {
       return true;
     }
   }
   return false;
 }
コード例 #2
0
 /**
  * Determine if the traversal has a step of a particular class.
  *
  * @param stepClass the step class to look for
  * @param traversal the traversal to perform the action on
  * @return {@code true} if the class is found and {@code false} otherwise
  */
 public static boolean hasStepOfClass(
     final Class stepClass, final Traversal.Admin<?, ?> traversal) {
   for (final Step<?, ?> step : traversal.getSteps()) {
     if (step.getClass().equals(stepClass)) {
       return true;
     }
   }
   return false;
 }
コード例 #3
0
 public static <S> List<S> getStepsOfClass(
     final Class<S> stepClass, final Traversal.Admin<?, ?> traversal) {
   List<S> steps = new ArrayList<>();
   for (Step step : traversal.getSteps()) {
     if (step.getClass().equals(stepClass)) {
       steps.add((S) step);
     }
   }
   return steps;
 }
コード例 #4
0
 public static <S> List<S> getStepsOfAssignableClassRecursively(
     final Class<S> stepClass, final Traversal.Admin<?, ?> traversal) {
   final List<S> list = new ArrayList<>();
   for (final Step<?, ?> step : traversal.getSteps()) {
     if (stepClass.isAssignableFrom(step.getClass())) list.add((S) step);
     if (step instanceof TraversalParent) {
       for (final Traversal.Admin<?, ?> globalChild :
           ((TraversalParent) step).getGlobalChildren()) {
         list.addAll(TraversalHelper.getStepsOfAssignableClassRecursively(stepClass, globalChild));
       }
     }
   }
   return list;
 }
コード例 #5
0
 /**
  * Determine if the traversal has a step of an assignable class in the current {@link Traversal}
  * and its child traversals.
  *
  * @param stepClass the step class to look for
  * @param traversal the traversal in which to look for the given step class
  * @return <code>true</code> if any step in the given traversal (and its child traversals) is an
  *     instance of the given <code>stepClass</code>, otherwise <code>false</code>.
  */
 public static boolean hasStepOfAssignableClassRecursively(
     final Class stepClass, final Traversal.Admin<?, ?> traversal) {
   for (final Step<?, ?> step : traversal.getSteps()) {
     if (stepClass.isAssignableFrom(step.getClass())) {
       return true;
     }
     if (step instanceof TraversalParent) {
       for (final Traversal.Admin<?, ?> globalChild :
           ((TraversalParent) step).getGlobalChildren()) {
         if (hasStepOfAssignableClassRecursively(stepClass, globalChild)) return true;
       }
     }
   }
   return false;
 }
コード例 #6
0
 /**
  * Determine if the traversal has any of the supplied steps of an assignable class in the current
  * {@link Traversal} and its child traversals.
  *
  * @param stepClasses the step classes to look for
  * @param traversal the traversal in which to look for the given step classes
  * @return <code>true</code> if any step in the given traversal (and its child traversals) is an
  *     instance of a class provided in <code>stepClasses</code>, otherwise <code>false</code>.
  */
 public static boolean hasStepOfAssignableClassRecursively(
     final Collection<Class> stepClasses, final Traversal.Admin<?, ?> traversal) {
   if (stepClasses.size() == 1)
     return hasStepOfAssignableClassRecursively(stepClasses.iterator().next(), traversal);
   for (final Step<?, ?> step : traversal.getSteps()) {
     if (IteratorUtils.anyMatch(
         stepClasses.iterator(), stepClass -> stepClass.isAssignableFrom(step.getClass()))) {
       return true;
     }
     if (step instanceof TraversalParent) {
       for (final Traversal.Admin<?, ?> globalChild :
           ((TraversalParent) step).getGlobalChildren()) {
         if (hasStepOfAssignableClassRecursively(stepClasses, globalChild)) return true;
       }
     }
   }
   return false;
 }