- java.lang.Object
-
- develop.toolkit.base.utils.ObjectAdvice
-
public final class ObjectAdvice extends Object
实例对象处理增强工具- 作者:
- qiushui on 2019-02-20.
-
-
构造器概要
构造器 构造器 说明 ObjectAdvice()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static Objectget(Object instance, Field field, boolean firstUseGetterMethod)反射获取值static Objectget(Object instance, String fieldName, boolean firstUseGetterMethod)反射获取值static <T> TnewInstanceQuietly(Class<T> clazz)安静地使用无参构造方法new对象static ObjectprimitiveTypeCast(String value, Class<?> clazz)字符串值转化成基本类型值static Map<Field,Object>readAllFieldValue(Object instance)读取全部字段值static voidset(Object instance, Field field, boolean firstUseSetterMethod)反射设置值static voidset(Object instance, String fieldName, boolean firstUseSetterMethod)反射设置值static <T> booleanvalueIn(T obj, T... targets)值是否在数组里static <T> booleanvalueNotIn(T obj, T... targets)值是否不在数组里
-
-
-
方法详细资料
-
valueIn
@SafeVarargs public static <T> boolean valueIn(@NonNull T obj, T... targets)
值是否在数组里
-
valueNotIn
@SafeVarargs public static <T> boolean valueNotIn(@NonNull T obj, T... targets)
值是否不在数组里
-
set
public static void set(Object instance, Field field, boolean firstUseSetterMethod)
反射设置值- 参数:
instance- 实例field- 字段firstUseSetterMethod- 优先使用setter方法
-
set
public static void set(Object instance, String fieldName, boolean firstUseSetterMethod)
反射设置值- 参数:
instance- 实例fieldName- 字段firstUseSetterMethod- 优先使用setter方法
-
get
public static Object get(Object instance, Field field, boolean firstUseGetterMethod)
反射获取值- 参数:
instance- 实例field- 字段firstUseGetterMethod- 优先使用getter方法- 返回:
- 反射值
-
get
public static Object get(Object instance, String fieldName, boolean firstUseGetterMethod)
反射获取值- 参数:
instance- 实例fieldName- 字段firstUseGetterMethod- 优先使用getter方法- 返回:
- 反射值
-
readAllFieldValue
public static Map<Field,Object> readAllFieldValue(Object instance)
读取全部字段值- 参数:
instance- 实例- 返回:
- 所有字段值
-
newInstanceQuietly
public static <T> T newInstanceQuietly(Class<T> clazz)
安静地使用无参构造方法new对象
-
-