Package org.fulib.fx.util
Class ReflectionUtil
java.lang.Object
org.fulib.fx.util.ReflectionUtil
Utility class containing different helper methods for the framework or the user.
Parts of this class are hacky and should be used with caution.
-
Method Summary
Modifier and TypeMethodDescriptiongetAllNonPrivateFieldsOrThrow(@NotNull Class<?> clazz, @NotNull Class<? extends @NotNull Annotation> annotation) Returns all non-private fields of the given class that are annotated with the given annotation.getAllNonPrivateMethodsOrThrow(@NotNull Class<?> clazz, @NotNull Class<? extends @NotNull Annotation> annotation) Returns all non-private methods of the given class that are annotated with the given annotation.static javafx.collections.ObservableList<javafx.scene.Node>getChildrenList(Class<?> clazz, javafx.scene.Parent parent) Returns the children list of the given parent.static ObjectgetInstanceOfProviderField(Field provider, Object instance) Returns an instance provided by the given provider field.static @Nullable MethodgetOverriding(@NotNull Method method) Checks if a method is overriding a method in one of the classes superclasses and returns the overridden method.static @Nullable Class<?>getProvidedClass(@NotNull Field providerField) Returns the class provided by the given provider field.static voidresetMouseHandler(javafx.stage.Stage stage) Resets the mouse handler of the given stage.
-
Method Details
-
getProvidedClass
Returns the class provided by the given provider field.- Parameters:
providerField- The provider field- Returns:
- The class provided by the provider field or null if the field is not a valid provider field
-
getChildrenList
public static javafx.collections.ObservableList<javafx.scene.Node> getChildrenList(Class<?> clazz, javafx.scene.Parent parent) Returns the children list of the given parent. This method is used to access the children list of a Parent class even though the method is not public in the Parent class. This should be used with caution and is mainly used for duplicating nodes.- Parameters:
clazz- The class to get the children list fromparent- The parent to get the children list from- Returns:
- The children list of the given parent
-
getInstanceOfProviderField
Returns an instance provided by the given provider field.- Parameters:
provider- The provider fieldinstance- The instance to get the provider from- Returns:
- The instance provided by the provider field
-
resetMouseHandler
public static void resetMouseHandler(javafx.stage.Stage stage) Resets the mouse handler of the given stage. This method is used to reset the mouse handler of a scene to avoid problems with mouse drag events. This should be used with caution and is mainly used for refreshing the scene.- Parameters:
stage- The stage to reset the mouse handler for
-
getAllNonPrivateFieldsOrThrow
public static Stream<Field> getAllNonPrivateFieldsOrThrow(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull Class<? extends @NotNull Annotation> annotation) Returns all non-private fields of the given class that are annotated with the given annotation. If a field is private, a RuntimeException is thrown.Utility method for not having to specify an error message every time.
- Parameters:
clazz- The class to get the fields fromannotation- The annotation to filter the fields by- Returns:
- A stream of fields that are annotated with the given annotation and are not private
-
getAllNonPrivateMethodsOrThrow
public static Stream<Method> getAllNonPrivateMethodsOrThrow(@NotNull @NotNull Class<?> clazz, @NotNull @NotNull Class<? extends @NotNull Annotation> annotation) Returns all non-private methods of the given class that are annotated with the given annotation. If a method is private, a RuntimeException is thrown.Utility method for not having to specify an error message every time.
- Parameters:
clazz- The class to get the methods fromannotation- The annotation to filter the methods by- Returns:
- A stream of methods that are annotated with the given annotation and are not private
-
getOverriding
Checks if a method is overriding a method in one of the classes superclasses and returns the overridden method.- Parameters:
method- The method to check- Returns:
- The overridden method, or null if there is none
-