当前位置: 首页>>代码示例>>Java>>正文


Java EntityField.setJavaType方法代码示例

本文整理汇总了Java中tk.mybatis.mapper.entity.EntityField.setJavaType方法的典型用法代码示例。如果您正苦于以下问题:Java EntityField.setJavaType方法的具体用法?Java EntityField.setJavaType怎么用?Java EntityField.setJavaType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tk.mybatis.mapper.entity.EntityField的用法示例。


在下文中一共展示了EntityField.setJavaType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFields

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * 获取全部的Field
 *
 * @param entityClass
 * @return
 */
public List<EntityField> getFields(Class<?> entityClass) {
    List<EntityField> fields = _getFields(entityClass, null, null);
    List<EntityField> properties = getProperties(entityClass);
    Set<EntityField> usedSet = new HashSet<EntityField>();
    for (EntityField field : fields) {
        for (EntityField property : properties) {
            if (!usedSet.contains(property) && field.getName().equals(property.getName())) {
                //泛型的情况下通过属性可以得到实际的类型
                field.setJavaType(property.getJavaType());
                break;
            }
        }
    }
    return fields;
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:22,代码来源:FieldHelper.java

示例2: getFields

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * 获取全部的Field
 *
 * @param entityClass
 * @return
 */
@Override
public List<EntityField> getFields(Class<?> entityClass) {
    List<EntityField> fields = _getFields(entityClass, null, null);
    List<EntityField> properties = getProperties(entityClass);
    Set<EntityField> usedSet = new HashSet<EntityField>();
    for (EntityField field : fields) {
        for (EntityField property : properties) {
            if (!usedSet.contains(property) && field.getName().equals(property.getName())) {
                //泛型的情况下通过属性可以得到实际的类型
                field.setJavaType(property.getJavaType());
                break;
            }
        }
    }
    return fields;
}
 
开发者ID:abel533,项目名称:Mapper,代码行数:23,代码来源:FieldHelper.java

示例3: getProperties

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * 通过方法获取属性
 *
 * @param entityClass
 * @return
 */
public List<EntityField> getProperties(Class<?> entityClass) {
    Map<String, Class<?>> genericMap = _getGenericTypeMap(entityClass);
    List<EntityField> entityFields = new ArrayList<EntityField>();
    BeanInfo beanInfo;
    try {
        beanInfo = Introspector.getBeanInfo(entityClass);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e);
    }
    PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
    for (PropertyDescriptor desc : descriptors) {
        if (desc != null && !"class".equals(desc.getName())) {
            EntityField entityField = new EntityField(null, desc);
            if (desc.getReadMethod() != null
                    && desc.getReadMethod().getGenericReturnType() != null
                    && desc.getReadMethod().getGenericReturnType() instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getReadMethod().getGenericReturnType()).getName()));
            } else if (desc.getWriteMethod() != null
                    && desc.getWriteMethod().getGenericParameterTypes() != null
                    && desc.getWriteMethod().getGenericParameterTypes().length == 1
                    && desc.getWriteMethod().getGenericParameterTypes()[0] instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getWriteMethod().getGenericParameterTypes()[0]).getName()));
            }
            entityFields.add(entityField);
        }
    }
    return entityFields;
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:35,代码来源:FieldHelper.java

示例4: _getProperties

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * 通过方法获取属性
 *
 * @param entityClass
 * @return
 */
private static List<EntityField> _getProperties(Class<?> entityClass) {
    Map<String, Class<?>> genericMap = _getGenericTypeMap(entityClass);
    List<EntityField> entityFields = new ArrayList<EntityField>();
    BeanInfo beanInfo = null;
    try {
        beanInfo = Introspector.getBeanInfo(entityClass);
    } catch (IntrospectionException e) {
        throw new RuntimeException(e);
    }
    PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
    for (PropertyDescriptor desc : descriptors) {
        if (desc != null && !"class".equals(desc.getName())) {
            EntityField entityField = new EntityField(null, desc);
            if (desc.getReadMethod() != null
                    && desc.getReadMethod().getGenericReturnType() != null
                    && desc.getReadMethod().getGenericReturnType() instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getReadMethod().getGenericReturnType()).getName()));
            } else if (desc.getWriteMethod() != null
                    && desc.getWriteMethod().getGenericParameterTypes() != null
                    && desc.getWriteMethod().getGenericParameterTypes().length == 1
                    && desc.getWriteMethod().getGenericParameterTypes()[0] instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getWriteMethod().getGenericParameterTypes()[0]).getName()));
            }
            entityFields.add(entityField);
        }
    }
    return entityFields;
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:35,代码来源:FieldTest.java

示例5: processAllColumns

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
private static void processAllColumns(Class<?> entityClass, List<EntityField> fieldList, Map<String, Class<?>> genericMap) {
    if (fieldList == null) {
        fieldList = new ArrayList<EntityField>();
    }
    if (entityClass == Object.class) {
        return;
    }
    Field[] fields = entityClass.getDeclaredFields();
    for (Field field : fields) {
        EntityField entityField = new EntityField(field, null);
        if (field.getGenericType() != null && field.getGenericType() instanceof TypeVariable) {
            if (genericMap == null || !genericMap.containsKey(((TypeVariable) field.getGenericType()).getName())) {
                throw new RuntimeException(entityClass + "字段" + field.getName() + "的泛型类型无法获取!");
            } else {
                entityField.setJavaType(genericMap.get(((TypeVariable) field.getGenericType()).getName()));
            }
        } else {
            entityField.setJavaType(field.getType());
        }
        fieldList.add(entityField);
    }

    Class<?> superClass = entityClass.getSuperclass();
    Map<String, Class<?>> _genericMap = null;
    if (entityClass.getGenericSuperclass() instanceof ParameterizedType) {
        Type[] types = ((ParameterizedType) entityClass.getGenericSuperclass()).getActualTypeArguments();
        TypeVariable[] typeVariables = superClass.getTypeParameters();
        if (typeVariables.length > 0) {
            _genericMap = new HashMap<String, Class<?>>();
            for (int i = 0; i < typeVariables.length; i++) {
                _genericMap.put(typeVariables[i].getName(), (Class<?>) types[i]);
            }
        }
    }
    processAllColumns(superClass, fieldList, _genericMap);
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:37,代码来源:FieldTest.java

示例6: getProperties

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * 通过方法获取属性
 *
 * @param entityClass
 * @return
 */
public List<EntityField> getProperties(Class<?> entityClass) {
    Map<String, Class<?>> genericMap = _getGenericTypeMap(entityClass);
    List<EntityField> entityFields = new ArrayList<EntityField>();
    BeanInfo beanInfo;
    try {
        beanInfo = Introspector.getBeanInfo(entityClass);
    } catch (IntrospectionException e) {
        throw new MapperException(e);
    }
    PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
    for (PropertyDescriptor desc : descriptors) {
        if (desc != null && !"class".equals(desc.getName())) {
            EntityField entityField = new EntityField(null, desc);
            if (desc.getReadMethod() != null
                    && desc.getReadMethod().getGenericReturnType() != null
                    && desc.getReadMethod().getGenericReturnType() instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getReadMethod().getGenericReturnType()).getName()));
            } else if (desc.getWriteMethod() != null
                    && desc.getWriteMethod().getGenericParameterTypes() != null
                    && desc.getWriteMethod().getGenericParameterTypes().length == 1
                    && desc.getWriteMethod().getGenericParameterTypes()[0] instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getWriteMethod().getGenericParameterTypes()[0]).getName()));
            }
            entityFields.add(entityField);
        }
    }
    return entityFields;
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:35,代码来源:FieldHelper.java

示例7: getProperties

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * 通过方法获取属性
 *
 * @param entityClass
 * @return
 */
@Override
public List<EntityField> getProperties(Class<?> entityClass) {
    Map<String, Class<?>> genericMap = _getGenericTypeMap(entityClass);
    List<EntityField> entityFields = new ArrayList<EntityField>();
    BeanInfo beanInfo;
    try {
        beanInfo = Introspector.getBeanInfo(entityClass);
    } catch (IntrospectionException e) {
        throw new MapperException(e);
    }
    PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors();
    for (PropertyDescriptor desc : descriptors) {
        if (desc != null && !"class".equals(desc.getName())) {
            EntityField entityField = new EntityField(null, desc);
            if (desc.getReadMethod() != null
                    && desc.getReadMethod().getGenericReturnType() != null
                    && desc.getReadMethod().getGenericReturnType() instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getReadMethod().getGenericReturnType()).getName()));
            } else if (desc.getWriteMethod() != null
                    && desc.getWriteMethod().getGenericParameterTypes() != null
                    && desc.getWriteMethod().getGenericParameterTypes().length == 1
                    && desc.getWriteMethod().getGenericParameterTypes()[0] instanceof TypeVariable) {
                entityField.setJavaType(genericMap.get(((TypeVariable) desc.getWriteMethod().getGenericParameterTypes()[0]).getName()));
            }
            entityFields.add(entityField);
        }
    }
    return entityFields;
}
 
开发者ID:abel533,项目名称:Mapper,代码行数:36,代码来源:FieldHelper.java

示例8: _getFields

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * @param entityClass
 * @param fieldList
 * @param genericMap
 * @param level
 */
private void _getFields(Class<?> entityClass, List<EntityField> fieldList, Map<String, Class<?>> genericMap, Integer level) {
    if (fieldList == null) {
        throw new NullPointerException("fieldList参数不能为空!");
    }
    if (level == null) {
        level = 0;
    }
    if (entityClass == Object.class) {
        return;
    }
    Field[] fields = entityClass.getDeclaredFields();
    int index = 0;
    for (Field field : fields) {
        //忽略static和transient字段#106
        if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) {
            EntityField entityField = new EntityField(field, null);
            if (field.getGenericType() != null && field.getGenericType() instanceof TypeVariable) {
                if (genericMap == null || !genericMap.containsKey(((TypeVariable) field.getGenericType()).getName())) {
                    throw new RuntimeException(entityClass + "字段" + field.getName() + "的泛型类型无法获取!");
                } else {
                    entityField.setJavaType(genericMap.get(((TypeVariable) field.getGenericType()).getName()));
                }
            } else {
                entityField.setJavaType(field.getType());
            }
            if (level.intValue() != 0) {
                //将父类的字段放在前面
                fieldList.add(index, entityField);
                index++;
            } else {
                fieldList.add(entityField);
            }
        }
    }
    //获取父类和泛型信息
    Class<?> superClass = entityClass.getSuperclass();
    //判断superClass
    if (superClass != null
            && !superClass.equals(Object.class)
            && (superClass.isAnnotationPresent(Entity.class)
            || (!Map.class.isAssignableFrom(superClass)
            && !Collection.class.isAssignableFrom(superClass)))) {
        level++;
        _getFields(superClass, fieldList, genericMap, level);
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:53,代码来源:FieldHelper.java

示例9: _getFields

import tk.mybatis.mapper.entity.EntityField; //导入方法依赖的package包/类
/**
 * @param entityClass
 * @param fieldList
 * @param genericMap
 * @param level
 */
private void _getFields(Class<?> entityClass, List<EntityField> fieldList, Map<String, Class<?>> genericMap, Integer level) {
    if (fieldList == null) {
        throw new NullPointerException("fieldList参数不能为空!");
    }
    if (level == null) {
        level = 0;
    }
    if (entityClass == Object.class) {
        return;
    }
    Field[] fields = entityClass.getDeclaredFields();
    int index = 0;
    for (Field field : fields) {
        //忽略static和transient字段#106
        if (!Modifier.isStatic(field.getModifiers()) && !Modifier.isTransient(field.getModifiers())) {
            EntityField entityField = new EntityField(field, null);
            if (field.getGenericType() != null && field.getGenericType() instanceof TypeVariable) {
                if (genericMap == null || !genericMap.containsKey(((TypeVariable) field.getGenericType()).getName())) {
                    throw new MapperException(entityClass + "字段" + field.getName() + "的泛型类型无法获取!");
                } else {
                    entityField.setJavaType(genericMap.get(((TypeVariable) field.getGenericType()).getName()));
                }
            } else {
                entityField.setJavaType(field.getType());
            }
            if (level.intValue() != 0) {
                //将父类的字段放在前面
                fieldList.add(index, entityField);
                index++;
            } else {
                fieldList.add(entityField);
            }
        }
    }
    //获取父类和泛型信息
    Class<?> superClass = entityClass.getSuperclass();
    //判断superClass
    if (superClass != null
            && !superClass.equals(Object.class)
            && (superClass.isAnnotationPresent(Entity.class)
            || (!Map.class.isAssignableFrom(superClass)
            && !Collection.class.isAssignableFrom(superClass)))) {
        level++;
        _getFields(superClass, fieldList, genericMap, level);
    }
}
 
开发者ID:godlike110,项目名称:tk-mybatis,代码行数:53,代码来源:FieldHelper.java


注:本文中的tk.mybatis.mapper.entity.EntityField.setJavaType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。