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 Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default boolean
abortVisit(T result)
Whether to abort the visit of further classes since the result is already satisfying.default T
apply(Class<?> cls, T result)
T
visit(Class<?> cls, T result)
Visits the designated class with the result so far.static <T> ReflectionTools.ClassVisitor<T>
visitAllWith(BiFunction<Class<?>,T,T> biFunct)
Creates a visitor that visits all classes with the designatedBiFunction
.static ReflectionTools.ClassVisitor<Boolean>
visitUntilTrue(Function<Class<?>,Boolean> funct)
Creates a visitor that visits all classes until the designatedFunction
returnstrue
.-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
apply
default T apply(Class<?> cls, T result)
- Specified by:
apply
in interfaceBiFunction<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 designatedBiFunction
. Note that at the first call the second parameter (result
) will benull
. So theBiFunction
usually has to create a corresponding result instance.- Parameters:
biFunct
- TheBiFunction
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 designatedFunction
returnstrue
.- Parameters:
funct
- TheFunction
to be applied when visiting classes.- Returns:
- A visitor that visits all classes with the designated
Function
until the function returnstrue
.
-
-