ml.shifu.guagua.util
类 ReflectionUtils

java.lang.Object
  继承者 ml.shifu.guagua.util.ReflectionUtils

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.


方法摘要
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.
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

方法详细信息

newInstance

public static <T> T newInstance(Class<T> clazz)
Create an object for the given class. The class should have constructor without any parameters.

参数:
clazz - class of which an object is created
返回:
a new object
抛出:
GuaguaRuntimeException - In case any exception for reflection.

newInstance

public static <T> T newInstance(String name)
Create an object for the given class. The class should have constructor without any parameters.

参数:
name - qualified class name.
返回:
a new object
抛出:
GuaguaRuntimeException - In case any exception for reflection.

hasEmptyParameterConstructor

public static boolean hasEmptyParameterConstructor(Class<?> clazz)
Check if there is empty-parameter constructor in one clazz.


getMethod

public static Method getMethod(Class<?> clazz,
                               String methodName)
Just to check if has method with methodName. This function only supports functions without parameters.



Copyright © 2015. All Rights Reserved.