protected MType getDictionaryType(MTypeContext context, Class<?> declaringType, Class<?> type, Type genericType, MTypeFactory root) { if(null == genericType) { return MDictionaryType.INSTANCE; } Type[] types = getDictionaryTypes(type, genericType); Type keyType = types[0]; Type valType = types[1]; MType keyMType = getMType(context, declaringType, Types.getActualType(keyType), keyType, root); MType valMType = getMType(context, declaringType, Types.getActualType(valType), valType, root); return new MDictionaryType(keyMType, valMType); }
return new MDictionaryType(MSimpleTypes.STRING, MObjectType.TYPE); throw new IllegalStateException("Invalid map type '" + typeName + "'"); return new MDictionaryType(MSimpleTypes.STRING, resolveType(api, valueType));
private static MType doResolveType(MetaApi api, MType type) { if(type instanceof MUnresolvedTypeRef) { return resolveType(api, ((MUnresolvedTypeRef) type).getRefTypeName()); } if(type instanceof MCollectionType) { return new MCollectionType(doResolveType(api, type.asCollectionType().getElementType())); } if(type instanceof MDictionaryType) { return new MDictionaryType(type.asDictionaryType().getKeyType(), doResolveType(api, type.asDictionaryType().getValueType())); } throw new IllegalStateException("Unsupported type '" + type + "'"); }
protected MType readObjectType(String name, JsonObject o) { JsonObject additionalProperties = o.getObject(ADDITIONAL_PROPERTIES); if(null == additionalProperties) { //check is nested model Object property = o.get(PROPERTIES); if(null != property && property instanceof Map) { if(null == name) { name = "Embedded"; } MApiModelBuilder model = readModel(name, o.asMap()); return model.toMComplexType().build(); }else { return MObjectType.TYPE; } }else{ if(additionalProperties.asMap().isEmpty()) { return MObjectType.TYPE; }else { MType valueType = readType(additionalProperties); return new MDictionaryType(MSimpleTypes.STRING, valueType); } } }