Class ReflexionPopulator
java.lang.Object
dev.derklaro.reflexion.ReflexionPopulator
Internal utility class to read all java.lang.reflect members from a class and its super classes.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull Set<Constructor<?>> getAllConstructors(@NotNull Class<?> declaringClass) Get all (declared) constructors in the given class, and it's super classes.getAllFields(@NotNull Class<?> declaringClass) Get all (declared) fields in the given class, and it's super classes.getAllMethods(@NotNull Class<?> declaringClass) Get all (declared) methods in the given class, and it's super classes.mappingHierarchyTravel(@NotNull Class<?> top, @NotNull Function<Class<?>, T[]> extractor) Travels down the class tree beginning from the given topmost class, extracting all public and declared members from each visited class (using the given extractor functions) and collects them into a set.
-
Constructor Details
-
ReflexionPopulator
private ReflexionPopulator()
-
-
Method Details
-
getAllFields
Get all (declared) fields in the given class, and it's super classes.- Parameters:
declaringClass- the class to start the search from.- Returns:
- all fields in the given class, and it's super classes.
- Throws:
NullPointerException- if the given topmost class is null.
-
getAllMethods
@NotNull public static @NotNull Set<Method> getAllMethods(@NotNull @NotNull Class<?> declaringClass) Get all (declared) methods in the given class, and it's super classes.- Parameters:
declaringClass- the class to start the search from.- Returns:
- all methods in the given class, and it's super classes.
- Throws:
NullPointerException- if the given topmost class is null.
-
getAllConstructors
@NotNull public static @NotNull Set<Constructor<?>> getAllConstructors(@NotNull @NotNull Class<?> declaringClass) Get all (declared) constructors in the given class, and it's super classes.- Parameters:
declaringClass- the class to start the search from.- Returns:
- all constructors in the given class and it's super classes.
- Throws:
NullPointerException- if the given topmost class is null.
-
mappingHierarchyTravel
@NotNull private static <T extends Member> @NotNull Set<T> mappingHierarchyTravel(@NotNull @NotNull Class<?> top, @NotNull @NotNull Function<Class<?>, T[]> extractor) Travels down the class tree beginning from the given topmost class, extracting all public and declared members from each visited class (using the given extractor functions) and collects them into a set. This method is not cached.- Type Parameters:
T- the type of member which gets extracted from the class tree.- Parameters:
top- the topmost class to start the search from.extractor- the extractor function for declared members.- Returns:
- all extracted members from the class tree.
- Throws:
NullPointerException- if the given topmost class or one of the extractor functions is null.
-