Class UtlReflection

java.lang.Object
io.github.darvil.utils.UtlReflection

public final class UtlReflection extends Object
  • Method Details

    • getSimpleName

      @NotNull public static @NotNull String getSimpleName(@NotNull @NotNull Class<?> clazz)
      Returns the simple name of the given class. If the class is an anonymous class, then the simple name of the superclass is returned.
      Parameters:
      clazz - The class to get the simple name of.
      Returns:
      The simple name of the given class.
    • hasParameters

      public static boolean hasParameters(Method method, Class<?>... paramTypes)
      Returns true if the given parameter types are assignable to the parameter types of the given method.
      Parameters:
      method - The method to check.
      paramTypes - The parameter types to check.
      Returns:
      true if the given parameter types are assignable to the parameter types of the given method.
    • instantiate

      public static <T> T instantiate(Class<T> clazz)
      Instantiates the given class with a no-argument constructor.
      Type Parameters:
      T - The type of the class.
      Parameters:
      clazz - The class to instantiate.
      Returns:
      The instantiated class. If the class could not be instantiated, a RuntimeException is thrown.
    • instantiate

      public static <T> T instantiate(Class<T> clazz, @NotNull @NotNull List<@NotNull Object> args)
      Instantiates the given class with the given arguments.
      Type Parameters:
      T - The type of the class.
      Parameters:
      clazz - The class to instantiate.
      args - The arguments to pass to the constructor.
      Returns:
      The instantiated class. If the class could not be instantiated, a RuntimeException is thrown.
    • instantiate

      public static <T> T instantiate(Class<T> clazz, @NotNull @NotNull List<? extends Class<?>> argTypes, @NotNull @NotNull List<Object> args)
      Instantiates the given class with the given arguments.
      Type Parameters:
      T - The type of the class.
      Parameters:
      clazz - The class to instantiate.
      argTypes - The types of the arguments to pass to the constructor.
      args - The arguments to pass to the constructor.
      Returns:
      The instantiated class. If the class could not be instantiated, a RuntimeException is thrown.