java.lang.Object
io.github.darvil.utils.UtlReflection
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringgetSimpleName(@NotNull Class<?> clazz) Returns the simple name of the given class.static booleanhasParameters(Method method, Class<?>... paramTypes) Returnstrueif the given parameter types are assignable to the parameter types of the given method.static <T> Tinstantiate(Class<T> clazz) Instantiates the given class with a no-argument constructor.static <T> TInstantiates the given class with the given arguments.static <T> Tinstantiate(Class<T> clazz, @NotNull List<@NotNull Object> args) Instantiates the given class with the given arguments.
-
Method Details
-
getSimpleName
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
Returnstrueif 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:
trueif the given parameter types are assignable to the parameter types of the given method.
-
instantiate
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
RuntimeExceptionis thrown.
-
instantiate
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
RuntimeExceptionis 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
RuntimeExceptionis thrown.
-