Class ReflectionUtil

java.lang.Object
org.fulib.fx.util.ReflectionUtil

public class ReflectionUtil extends Object
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 Details

    • getProvidedClass

      @Nullable public static @Nullable Class<?> getProvidedClass(@NotNull @NotNull Field providerField)
      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 from
      parent - The parent to get the children list from
      Returns:
      The children list of the given parent
    • getInstanceOfProviderField

      public static Object getInstanceOfProviderField(Field provider, Object instance)
      Returns an instance provided by the given provider field.
      Parameters:
      provider - The provider field
      instance - 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 from
      annotation - 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 from
      annotation - The annotation to filter the methods by
      Returns:
      A stream of methods that are annotated with the given annotation and are not private