Interface ReflectionTools.ClassVisitor<T>

Type Parameters:
T - The type of result of this visitor.
All Superinterfaces:
BiFunction<Class<?>,T,T>
Enclosing class:
ReflectionTools

public static interface ReflectionTools.ClassVisitor<T> extends BiFunction<Class<?>,T,T>
Interface for visiting a class hierarchy and accumulating the result. The visit of further classes of the hierarchy can be aborted any time.
  • Method Details

    • apply

      default T apply(Class<?> cls, T result)
      Specified by:
      apply in interface BiFunction<Class<?>,T,T>
    • visit

      T visit(Class<?> cls, T result)
      Visits the designated class with the result so far. The new result is returned after the visit.
      Parameters:
      cls - The visited class.
      result - The result before the visit.
      Returns:
      The result after the visit.
    • abortVisit

      default boolean abortVisit(T result)
      Whether to abort the visit of further classes since the result is already satisfying.

      Per default this visitor will visit all classes and not abort early.

      Parameters:
      result - The result accumulated by the previous visits.
      Returns:
      Whether to abort visiting the rest of the class hierarchy.
    • visitAllWith

      static <T> ReflectionTools.ClassVisitor<T> visitAllWith(BiFunction<Class<?>,T,T> biFunct)
      Creates a visitor that visits all classes with the designated BiFunction. Note that at the first call the second parameter (result) will be null. So the BiFunction usually has to create a corresponding result instance.
      Parameters:
      biFunct - The BiFunction to be applied when visiting classes.
      Returns:
      A visitor that visits all classes with the designated BiFunction.
    • visitUntilTrue

      static ReflectionTools.ClassVisitor<Boolean> visitUntilTrue(Function<Class<?>,Boolean> funct)
      Creates a visitor that visits all classes until the designated Function returns true.
      Parameters:
      funct - The Function to be applied when visiting classes.
      Returns:
      A visitor that visits all classes with the designated Function until the function returns true.