public final class ReflectionUtils extends Object
ReflectionUtils is used to get instance from java reflection mechanism.
The class should have default constructor for getting instance.
Constructors are cached but instances are not cached. Each time you will get a new instance.
| Modifier and Type | Method and Description |
|---|---|
static Method |
getMethod(Class<?> clazz,
String methodName)
Just to check if has method with methodName.
|
static boolean |
hasEmptyParameterConstructor(Class<?> clazz)
Check if there is empty-parameter constructor in one
clazz. |
static <T> T |
newInstance(Class<T> clazz)
Create an object for the given class.
|
static <T> T |
newInstance(String name)
Create an object for the given class.
|
public static <T> T newInstance(Class<T> clazz)
clazz - class of which an object is createdGuaguaRuntimeException - In case any exception for reflection.public static <T> T newInstance(String name)
name - qualified class name.GuaguaRuntimeException - In case any exception for reflection.public static boolean hasEmptyParameterConstructor(Class<?> clazz)
clazz.Copyright © 2019. All Rights Reserved.