Class ControllerUtil

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

public class ControllerUtil extends Object
  • Field Details

    • EVENT_ANNOTATIONS

      public static final Set<Class<? extends Annotation>> EVENT_ANNOTATIONS
  • Method Details

    • isComponent

      public static boolean isComponent(@Nullable @Nullable Object instance)
      Checks if an instance is a component (controller extending a Node).

      This method is used internally by the framework and shouldn't be required for developers.

      Parameters:
      instance - The instance to check
      Returns:
      True if the instance is a component (controller extending a Node)
    • isComponent

      public static boolean isComponent(@Nullable @Nullable Class<?> clazz)
      Checks if a class is a component (controller extending a Node).

      This method is used internally by the framework and shouldn't be required for developers.

      Parameters:
      clazz - The clazz to check
      Returns:
      True if the clazz is a component (controller extending a Node)
    • isControllerOrComponent

      public static boolean isControllerOrComponent(@Nullable @Nullable Object instance)
      Checks if an instance is a controller or a component.

      This method is used internally by the framework and shouldn't be required for developers.

      Parameters:
      instance - The instance to check
      Returns:
      True if the instance is a controller or component
    • isController

      public static boolean isController(@Nullable @Nullable Object instance)
      Checks if an instance is a controller.

      This method is used internally by the framework and shouldn't be required for developers.

      Parameters:
      instance - The instance to check
      Returns:
      True if the instance is a controller
    • isController

      public static boolean isController(@Nullable @Nullable Class<?> clazz)
      Checks if a class is a controller.

      This method is used internally by the framework and shouldn't be required for developers.

      Parameters:
      clazz - The class to check
      Returns:
      True if the class is a controller
    • canProvideSubComponent

      public static boolean canProvideSubComponent(Field field)
      Checks if the given field is a field that can provide a component.
      Parameters:
      field - The field to check
      Returns:
      True if the field is a field that can provide a component
    • transform

      @NotNull public static @NotNull String transform(@NotNull @NotNull String className)
      Transforms a class name to a fxml file name or id using the default naming scheme. Used if no path is specified in the Controller.view() annotation.

      Example: ExampleController --> example

      Note that this method could result in funky names if the class name doesn't follow the naming scheme.

      Parameters:
      className - The name of the class (should be Class.getName() or Class.getSimpleName()
      Returns:
      The transformed name
    • requireControllerProvider

      public static void requireControllerProvider(@NotNull @NotNull Field field)
      Checks if the given field is a valid route field. A valid route field is a field that is annotated with Route and is of type Provider where the generic type is a class annotated with Controller or Component.
      Parameters:
      field - The field to check
      Throws:
      InvalidRouteFieldException - If the field is not a valid route field
    • isEventMethod

      public static boolean isEventMethod(@NotNull @NotNull Method method)
      Checks whether a method is annotated with an event annotation such as OnKey or OnRender.
      Parameters:
      method - The method to check
      Returns:
      Whether the method is annotated with an event annotation
    • checkOverrides

      public static void checkOverrides(Method method)
      Utility method for checking if a method overrides another event method.

      If a method overrides another method and the overridden method is an event method, calling the superclass method results in the subclass method being called twice due to how java handles method overrides.

      Parameters:
      method - The method to check