public class ReflectUtil extends Object
| 构造器和说明 |
|---|
ReflectUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <E> org.springframework.data.jpa.domain.Specification<E> |
createOneSpecification(String attr,
String condition)
指定条件查询
|
static <E> org.springframework.data.jpa.domain.Specification<E> |
createSpecification(Map<String,String> objConditions,
Class<E> clazz,
List<String> excludeLikeAttr)
生成全属性条件查询通用Specification
|
static Object |
executeMethod(Object object,
String methodName,
Object... parameters)
通过方法名动态执行某个方法
|
static Map<String,Class<?>> |
getFields(Object object)
获取对象所有属性及对应的类别
|
static Map<String,Object> |
getFieldsValue(Object object)
获取所有属性值
|
static <E> javax.persistence.criteria.Path<E> |
getRootPath(javax.persistence.criteria.Root<E> root,
javax.persistence.criteria.Path<E> path,
String allPath)
获取关联查询真实path
|
static Map<String,String> |
getStringValues(Object object)
获取所有属性值,自动转为字符串
|
static List<Field> |
getTargetAnnoation(Class<?> objectClass,
Class<? extends Annotation> annoClass)
获取拥有指定注解的字段
|
static Map<String,Object> |
getValues(Object object)
获取所有属性值
|
static Boolean |
setValue(Object object,
String property,
Object value)
设置属性值
|
public static <E> org.springframework.data.jpa.domain.Specification<E> createSpecification(Map<String,String> objConditions, Class<E> clazz, List<String> excludeLikeAttr)
E - 泛型objConditions - 属性参数clazz - 要查询的实体类或vo类excludeLikeAttr - 不使用模糊搜索的字符串属性public static <E> org.springframework.data.jpa.domain.Specification<E> createOneSpecification(String attr, String condition)
E - 泛型attr - 查询的字段condition - 条件public static <E> javax.persistence.criteria.Path<E> getRootPath(javax.persistence.criteria.Root<E> root,
javax.persistence.criteria.Path<E> path,
String allPath)
E - Eroot - rootpath - pathallPath - allPathpublic static Object executeMethod(Object object, String methodName, Object... parameters) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException
object - objectmethodName - 方法名parameters - 参数InvocationTargetException - InvocationTargetExceptionIllegalAccessException - IllegalAccessExceptionNoSuchMethodException - NoSuchMethodExceptionpublic static Map<String,Object> getFieldsValue(Object object) throws IllegalAccessException
object - objectIllegalAccessException - IllegalAccessExceptionpublic static Boolean setValue(Object object, String property, Object value) throws NoSuchFieldException, IllegalAccessException
property - 设置的字段value - 值object - objectNoSuchFieldExceptionIllegalAccessExceptionpublic static Map<String,Class<?>> getFields(Object object) throws IllegalAccessException
object - objectIllegalAccessException - IllegalAccessExceptionpublic static Map<String,Object> getValues(Object object) throws IllegalAccessException
object - objectIllegalAccessException - IllegalAccessExceptionpublic static Map<String,String> getStringValues(Object object) throws IllegalAccessException
object - objectIllegalAccessException - IllegalAccessExceptionpublic static List<Field> getTargetAnnoation(Class<?> objectClass, Class<? extends Annotation> annoClass)
objectClass - 对象annoClass - 查询的注解Copyright © 2023. All Rights Reserved.