Search in sources :

Example 1 with Transient

use of com.github.dreamroute.mybatis.pro.core.annotations.Transient in project mybatis-pro by Dreamroute.

the class ClassUtil method getAllFields.

/**
 * 获取实体所有JavaBean属性:
 * <ol>
 *     <li>JavaBean属性</li>
 *     <li>未被@Transient标记</li>
 * </ol>
 */
public static Set<Field> getAllFields(Class<?> cls) {
    Field[] fs = getFields(cls);
    Reflector r = new Reflector(cls);
    return Arrays.stream(fs).filter(f -> isJavaBeanProp(r, f)).collect(Collectors.toSet());
}
Also used : CollectionUtils.isEmpty(org.springframework.util.CollectionUtils.isEmpty) Arrays(java.util.Arrays) MyBatisProException(com.github.dreamroute.mybatis.pro.core.exception.MyBatisProException) Collectors.counting(java.util.stream.Collectors.counting) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) AnnotatedElementUtils.hasAnnotation(org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation) Id(com.github.dreamroute.mybatis.pro.core.annotations.Id) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) JsonUtil.toJsonStr(com.github.dreamroute.mybatis.pro.base.codec.enums.JsonUtil.toJsonStr) Transient(com.github.dreamroute.mybatis.pro.core.annotations.Transient) Mapper(com.github.dreamroute.mybatis.pro.sdk.Mapper) Collectors.toMap(java.util.stream.Collectors.toMap) Map(java.util.Map) Method(java.lang.reflect.Method) Collectors.toSet(java.util.stream.Collectors.toSet) Insert(org.apache.ibatis.annotations.Insert) Select(org.apache.ibatis.annotations.Select) Reflector(org.apache.ibatis.reflection.Reflector) Delete(org.apache.ibatis.annotations.Delete) ObjectUtils(org.springframework.util.ObjectUtils) Set(java.util.Set) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) List(java.util.List) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ReflectUtil.getFields(cn.hutool.core.util.ReflectUtil.getFields) Entry(java.util.Map.Entry) Function.identity(java.util.function.Function.identity) Update(org.apache.ibatis.annotations.Update) Arrays.stream(java.util.Arrays.stream) Field(java.lang.reflect.Field) Reflector(org.apache.ibatis.reflection.Reflector)

Aggregations

ReflectUtil.getFields (cn.hutool.core.util.ReflectUtil.getFields)1 JsonUtil.toJsonStr (com.github.dreamroute.mybatis.pro.base.codec.enums.JsonUtil.toJsonStr)1 Id (com.github.dreamroute.mybatis.pro.core.annotations.Id)1 Transient (com.github.dreamroute.mybatis.pro.core.annotations.Transient)1 MyBatisProException (com.github.dreamroute.mybatis.pro.core.exception.MyBatisProException)1 Mapper (com.github.dreamroute.mybatis.pro.sdk.Mapper)1 Field (java.lang.reflect.Field)1 Method (java.lang.reflect.Method)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Arrays.stream (java.util.Arrays.stream)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Function.identity (java.util.function.Function.identity)1 Collectors (java.util.stream.Collectors)1