Class ReflectionUtils

java.lang.Object
me.unurled.srcore.utils.ReflectionUtils

public class ReflectionUtils extends Object
The ReflectionUtils class is a class that is used to reflect classes and methods.
  • Method Details

    • getClass

      @NotNull public static <T> @NotNull Class<T> getClass(@NotNull @NotNull String path)
      Get a class from a path
      Type Parameters:
      T - a type of class
      Parameters:
      path - The path of the class
      Returns:
      The class
    • getClassOrNull

      @Nullable public static <T> @Nullable Class<T> getClassOrNull(@NotNull @NotNull String path)
      Get a class from a path
      Type Parameters:
      T - a type of class
      Parameters:
      path - The path of the class
      Returns:
      The class or null
    • getMethodOrNull

      @Nullable public static @Nullable Method getMethodOrNull(@NotNull @NotNull Class<?> clazz, boolean declared, @NotNull @NotNull String name, @NotNull @NotNull Class<?> @NotNull ... parameterTypes)
      Get a method from a class
      Parameters:
      clazz - The class
      declared - If the method is declared
      name - The name of the method
      parameterTypes - The parameter types of the method
      Returns:
      The method
    • getField

      @NotNull public static @NotNull Field getField(@NotNull @NotNull Class<?> clazz, boolean declared, @NotNull @NotNull String name)
      Get a method from a class
      Parameters:
      clazz - The class
      declared - If the method is declared
      name - The name of the method
      Returns:
      The method
    • getFieldValue

      @Nullable public static <T> T getFieldValue(@NotNull @NotNull Field field, @Nullable @Nullable Object obj)
      Get a field from a class
      Type Parameters:
      T - a type of field
      Parameters:
      field - The field
      obj - The object
      Returns:
      The field value
    • invokeMethod

      public static <T> T invokeMethod(@NotNull @NotNull Method method, @Nullable @Nullable Object obj, @Nullable @Nullable Object @Nullable ... args)
      Invoke a method
      Type Parameters:
      T - a type of method
      Parameters:
      method - The method
      obj - The object
      args - The arguments
      Returns:
      The method value