com.github.drinkjava2.jdialects
Class ClassCacheUtils

java.lang.Object
  extended by com.github.drinkjava2.jdialects.ClassCacheUtils

public abstract class ClassCacheUtils
extends Object

ClassCacheUtils is utility class to cache some info of classes read and write method

Since:
1.0.0
Author:
Yong Zhu (Yong9981@gmail.com)

Nested Class Summary
protected static class ClassCacheUtils.ClassOrMethodNotExist
           
 
Field Summary
protected static ConcurrentHashMap<String,Class<?>> classExistCache
           
protected static Map<Class<?>,Map<String,Method>> classReadMethods
           
protected static Map<Class<?>,Map<String,Method>> classWriteMethods
           
protected static Map<Class<?>,Map<String,Object>> uniqueMethodCache
           
 
Constructor Summary
ClassCacheUtils()
           
 
Method Summary
static void cacheReadWriteMethodsAndBoxField(Class<?> clazz)
           
static Class<?> checkClassExist(String className)
          Check class if exist, if exit return it, otherwise return null
static Method checkMethodExist(Class<?> clazz, String uniqueMethodName)
          Check if a unique method name exists in class, if exist return the method, otherwise return null
static Object createNewEntity(Class<?> entityClass)
          Create a new Object by given entityClass, if any exception happen, throw DialectException
static Method getClassFieldReadMethod(Class<?> clazz, String fieldName)
          Return cached class field read method to avoid each time use reflect
static Method getClassFieldWriteMethod(Class<?> clazz, String fieldName)
          Return cached class field write method to avoid each time use reflect
static Map<String,Method> getClassReadMethods(Class<?> clazz)
          Return cached class read methods to avoid each time use reflect
static Map<String,Method> getClassWriteMethods(Class<?> clazz)
          Return cached class write methods to avoid each time use reflect
static Object readValueFromBeanField(Object entityBean, String fieldName)
          Read value from entityBean field
static void registerClass(Class<?> clazz)
           
static void writeValueToBeanField(Object entityBean, String fieldName, Object value)
          write value to entityBean field
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

classExistCache

protected static ConcurrentHashMap<String,Class<?>> classExistCache

uniqueMethodCache

protected static Map<Class<?>,Map<String,Object>> uniqueMethodCache

classReadMethods

protected static Map<Class<?>,Map<String,Method>> classReadMethods

classWriteMethods

protected static Map<Class<?>,Map<String,Method>> classWriteMethods
Constructor Detail

ClassCacheUtils

public ClassCacheUtils()
Method Detail

checkClassExist

public static Class<?> checkClassExist(String className)
Check class if exist, if exit return it, otherwise return null


registerClass

public static void registerClass(Class<?> clazz)

checkMethodExist

public static Method checkMethodExist(Class<?> clazz,
                                      String uniqueMethodName)
Check if a unique method name exists in class, if exist return the method, otherwise return null


cacheReadWriteMethodsAndBoxField

public static void cacheReadWriteMethodsAndBoxField(Class<?> clazz)

getClassReadMethods

public static Map<String,Method> getClassReadMethods(Class<?> clazz)
Return cached class read methods to avoid each time use reflect


getClassFieldReadMethod

public static Method getClassFieldReadMethod(Class<?> clazz,
                                             String fieldName)
Return cached class field read method to avoid each time use reflect


getClassWriteMethods

public static Map<String,Method> getClassWriteMethods(Class<?> clazz)
Return cached class write methods to avoid each time use reflect


getClassFieldWriteMethod

public static Method getClassFieldWriteMethod(Class<?> clazz,
                                              String fieldName)
Return cached class field write method to avoid each time use reflect


readValueFromBeanField

public static Object readValueFromBeanField(Object entityBean,
                                            String fieldName)
Read value from entityBean field


writeValueToBeanField

public static void writeValueToBeanField(Object entityBean,
                                         String fieldName,
                                         Object value)
write value to entityBean field


createNewEntity

public static Object createNewEntity(Class<?> entityClass)
Create a new Object by given entityClass, if any exception happen, throw DialectException



Copyright © 2018. All rights reserved.