public static MType getMType(Class<?> type) { return getMType(type, null); }
void mappingBeanProperty(MetaField f, BeanProperty bp) { if(null == bp) { return; } if(null != bp && !Strings.isEmpty(f.getType())) { MType mtype = MTypes.getMType(bp.getType(), bp.getGenericType()); if(mtype.isSimpleType()) { f.setType(mtype.asSimpleType().getJdbcType().getName()); if(MSimpleTypes.STRING.equals(mtype) && null == f.getLength()) { f.setLength(255); } } } }
public MetaModel read(Resource file) { String content = file.getContent().trim(); if (content.length() == 0) { return null; } String name = Strings.upperFirst(Paths.getFileNameWithoutExtension(file.getFilename())); JsonObject o = JSON.parse(file.getContent()).asJsonObject(); if(o.asMap().isEmpty()) { return null; } MetaModel model = JSON.convert(o.asMap(), MetaModel.class); if (!Strings.isEmpty(model.getClassName())) { Class<?> c = Classes.tryForName(model.getClassName()); if (null == c) { throw new IllegalStateException("Model class '" + model.getClassName() + "' not found!"); } MType type = MTypes.getMType(c); if (!type.isComplexType()) { throw new IllegalStateException("The model class '" + model.getClassName() + "' must be complex type!"); } MetaUtils.tryCopyModel(type.asComplexType(), model); } MApiModelBuilder am = nonValidateSwaggerReader.readModel(name, o.asMap(), new SwaggerTypeEx()); MetaUtils.tryCopyModel(am, model); validator.validate("Model(" + model.getName() + ")", model); return model; }
protected void mappingBeanProperties(MetadataContext context, EntityMappingBuilder emb, BeanType beanType) { for(BeanProperty bp : beanType.getProperties()){ if(isExplicitNonField(context,bp)){ continue; } if(isExplicitRelation(context, bp)) { RelationMappingBuilder rmb = new RelationMappingBuilder(bp); preMappingRelation(context, emb, rmb); postMappingRelation(context, emb, rmb); emb.addRelationMapping(rmb); } if( isExplicitField(context,bp) || (!context.getConfig().isMappingFieldExplicitly() && isConventionalField(context,bp))){ FieldMappingBuilder fmb = new FieldMappingBuilder(); fmb.setBeanProperty(bp); fmb.setJavaType(bp.getType()); fmb.setDataType(MTypes.getMType(bp.getType(), bp.getGenericType())); preMappingField(context, emb, fmb); postMappingField(context, emb, fmb); emb.addFieldMapping(fmb); } } }
p.setType(f.getResolvedType()); }else { p.setType(MTypes.getMType(JdbcTypes.forTypeName(f.getType()).getDefaultReadType()));
}else{ fm.setJavaType(jdbcType.getDefaultReadType()); fm.setDataType(MTypes.getMType(fm.getJavaType()));