类 ReflectionUtils
- java.lang.Object
-
- io.microsphere.util.BaseUtils
-
- io.microsphere.reflect.ReflectionUtils
-
public abstract class ReflectionUtils extends BaseUtils
Reflection Utility class , generic methods are defined fromFieldUtils
,MethodUtils
,ConstructorUtils
- 从以下版本开始:
- 1.0.0
- 版本:
- 1.0.0
- 作者:
- Mercy
- 另请参阅:
Method
,Field
,Constructor
,Array
,MethodUtils
,FieldUtils
,ConstructorUtils
-
-
字段概要
字段 修饰符和类型 字段 说明 static java.lang.String
SUN_REFLECT_REFLECTION_CLASS_NAME
Sun JDK implementation class: full name of sun.reflect.Reflection
-
构造器概要
构造器 构造器 说明 ReflectionUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static void
assertArrayIndex(java.lang.Object array, int index)
Assert array indexstatic void
assertArrayType(java.lang.Object array)
Assert the object is array or notstatic void
assertFieldMatchType(java.lang.Object object, java.lang.String fieldName, java.lang.Class<?> expectedType)
Assert Field type matchstatic <T> java.util.Set<java.lang.Class<T>>
findHierarchicalTypes(java.lang.Class<?> sourceClass, java.lang.Class<T> matchType)
Find the hierarchical types from the sourceclass
by specifiedtype
.static java.util.Set<java.lang.reflect.ParameterizedType>
findParameterizedTypes(java.lang.Class<?> sourceClass)
Find theSet
ofParameterizedType
static java.lang.Class<?>
getCallerClass()
Get caller classstatic java.lang.Class<?>
getCallerClass(int invocationFrame)
Get the caller classstatic java.lang.String
getCallerClassName()
Get Caller classstatic <T> T
getProperty(java.lang.Object bean, java.lang.String methodName)
Get the value from the specified bean and its getter method.static boolean
isSupportedSunReflectReflection()
Is supported sun.reflect.Reflection or notstatic java.util.Map<java.lang.String,java.lang.Object>
readFieldsAsMap(java.lang.Object object)
Read fields value asMap
static java.lang.Class[]
resolveTypes(java.lang.Object... values)
Resolve the types of the specified valuesstatic <T> java.util.List<T>
toList(java.lang.Object array)
ConvertArray
object toList
-
-
-
字段详细资料
-
SUN_REFLECT_REFLECTION_CLASS_NAME
public static final java.lang.String SUN_REFLECT_REFLECTION_CLASS_NAME
Sun JDK implementation class: full name of sun.reflect.Reflection- 另请参阅:
- 常量字段值
-
-
方法详细资料
-
isSupportedSunReflectReflection
public static boolean isSupportedSunReflectReflection()
Is supported sun.reflect.Reflection or not- 返回:
true
if supported
-
getCallerClassName
@Nonnull public static java.lang.String getCallerClassName()
Get Caller class- 返回:
- Get the Class name that called the method
-
getCallerClass
@Nonnull public static java.lang.Class<?> getCallerClass() throws java.lang.IllegalStateException
Get caller class For instance,package com.acme; import ...; class Foo { public void bar(){ } }
- 返回:
- Get caller class
- 抛出:
java.lang.IllegalStateException
- If the caller class cannot be found
-
getCallerClass
public static java.lang.Class<?> getCallerClass(int invocationFrame)
Get the caller class- 参数:
invocationFrame
- The frame of method invocation- 返回:
null
if not found
-
assertArrayIndex
public static void assertArrayIndex(java.lang.Object array, int index) throws java.lang.IllegalArgumentException
Assert array index- 参数:
array
- Array objectindex
- index- 抛出:
java.lang.IllegalArgumentException
- seeassertArrayType(Object)
java.lang.ArrayIndexOutOfBoundsException
- Ifindex
is less than 0 or equals or greater than length of array
-
assertArrayType
public static void assertArrayType(java.lang.Object array) throws java.lang.IllegalArgumentException
Assert the object is array or not- 参数:
array
- asserted object- 抛出:
java.lang.IllegalArgumentException
- if the object is not a array
-
assertFieldMatchType
public static void assertFieldMatchType(java.lang.Object object, java.lang.String fieldName, java.lang.Class<?> expectedType) throws java.lang.IllegalArgumentException
Assert Field type match- 参数:
object
- ObjectfieldName
- field nameexpectedType
- expected type- 抛出:
java.lang.IllegalArgumentException
- if type is not matched
-
toList
@Nonnull public static <T> java.util.List<T> toList(java.lang.Object array) throws java.lang.IllegalArgumentException
ConvertArray
object toList
- 参数:
array
- array object- 返回:
List
- 抛出:
java.lang.IllegalArgumentException
- if the object argument is not an array
-
readFieldsAsMap
@Nonnull public static java.util.Map<java.lang.String,java.lang.Object> readFieldsAsMap(java.lang.Object object)
Read fields value asMap
- 参数:
object
- object to be read- 返回:
- fields value as
Map
-
findParameterizedTypes
public static java.util.Set<java.lang.reflect.ParameterizedType> findParameterizedTypes(java.lang.Class<?> sourceClass)
Find theSet
ofParameterizedType
- 参数:
sourceClass
- the sourceclass
- 返回:
- non-null read-only
Set
-
findHierarchicalTypes
public static <T> java.util.Set<java.lang.Class<T>> findHierarchicalTypes(java.lang.Class<?> sourceClass, java.lang.Class<T> matchType)
Find the hierarchical types from the sourceclass
by specifiedtype
.- 类型参数:
T
- the type to match- 参数:
sourceClass
- the sourceclass
matchType
- the type to match- 返回:
- non-null read-only
Set
-
getProperty
public static <T> T getProperty(java.lang.Object bean, java.lang.String methodName)
Get the value from the specified bean and its getter method.- 类型参数:
T
- the type of property value- 参数:
bean
- the bean instancemethodName
- the name of getter- 返回:
-
resolveTypes
public static java.lang.Class[] resolveTypes(java.lang.Object... values)
Resolve the types of the specified values- 参数:
values
- the values- 返回:
- If can't be resolved, return
empty class array
-
-