com.dyuproject.util.reflect
Class ReflectUtil

java.lang.Object
  extended by com.dyuproject.util.reflect.ReflectUtil

public final class ReflectUtil
extends Object

Util for java reflections

Author:
David Yu
Date created:
Mar 14, 2008

Constructor Summary
ReflectUtil()
           
 
Method Summary
static Map<String,Method> getGetterMethods(Class<?> pojoClass)
          Gets the getters of a pojo as a map of String as key and Method as value.
static Object getInstance(Class<?> clazz)
          Tries to invoke Foo.getInstance() if the method (public+static) getInstance() is there.
static Map<String,Method> getSetterMethods(Class<?> pojoClass)
          Gets the setters of a pojo as a map of String as key and Method as value.
static Object newInstance(Class<?> clazz)
          Tries to invoke Foo.getInstance() if the method (public+static) getInstance() is there; If not, it creates a new instance via reflection.
static String toField(int start, String methodName)
          Converts a method name into a camel-case field name, starting from start.
static String toProperty(int start, String methodName)
          Converts a method name into a camel-case field name, starting from start.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ReflectUtil

public ReflectUtil()
Method Detail

getGetterMethods

public static Map<String,Method> getGetterMethods(Class<?> pojoClass)
Gets the getters of a pojo as a map of String as key and Method as value.


getSetterMethods

public static Map<String,Method> getSetterMethods(Class<?> pojoClass)
Gets the setters of a pojo as a map of String as key and Method as value.


toProperty

public static String toProperty(int start,
                                String methodName)
Converts a method name into a camel-case field name, starting from start.


toField

public static String toField(int start,
                             String methodName)
Converts a method name into a camel-case field name, starting from start.


getInstance

public static Object getInstance(Class<?> clazz)
Tries to invoke Foo.getInstance() if the method (public+static) getInstance() is there.


newInstance

public static Object newInstance(Class<?> clazz)
                          throws InstantiationException,
                                 IllegalAccessException
Tries to invoke Foo.getInstance() if the method (public+static) getInstance() is there; If not, it creates a new instance via reflection.

Throws:
InstantiationException
IllegalAccessException


Copyright © 2008-2013. All Rights Reserved.