public void setMProperty(MProperty mp) { this.metaProperty = mp; this.beanProperty = mp.getBeanProperty(); this.name = mp.getName(); this.title = mp.getTitle(); this.summary = mp.getSummary(); this.description = mp.getDescription(); this.metaProperty = mp; this.type = mp.getType(); this.defaultValue = mp.getDefaultValue(); this.enumValues = mp.getEnumValues(); this.required = mp.getRequired(); this.identity = mp.isIdentity(); this.unique = mp.isUnique(); this.reference = mp.isReference(); this.discriminator = mp.isDiscriminator(); this.selectable = mp.getSelectable(); this.aggregatable = mp.getAggregatable(); this.groupable = mp.getGroupable(); this.creatable = mp.getCreatable(); this.updatable = mp.getUpdatable(); this.sortable = mp.getSortable(); this.filterable = mp.getFilterable();
@Override public MProperty build() { return new MProperty(name, title, summary, description, type, beanProperty, identity, unique, required, defaultValue, enumValues, fixedLength, length, precision, scale, discriminator, selectable, aggregatable, groupable, creatable, updatable, sortable, filterable, reference); }
public MProperty getProperty(String name) { for(MProperty p : properties) { if(p.getName().equals(name)) { return p; } } return null; } }
private void onTypeResolved(MType mtype) { if (mtype.isComplexType()) { MComplexType ct = mtype.asComplexType(); if (!complexTypes.containsKey(ct.getJavaType())) { listener.onComplexTypeResolved(ct.getJavaType(), mtype.asComplexType()); complexTypes.put(ct.getJavaType(), ct); } for (MProperty p : ct.getProperties()) { onTypeResolved(p.getType()); } } else if (mtype.isCollectionType()) { MType elementType = mtype.asCollectionType().getElementType(); onTypeResolved(elementType); } } }
public MApiModelBuilder(MComplexType type, String name) { this.type = type; this.name = Strings.isEmpty(name) ? type.getName() : name; this.title = type.getTitle(); this.summary = type.getSummary(); this.description = type.getDescription(); this.entity = type.isEntity(); boolean annotatedOnly = false; if(null != type.getJavaType()) { this.javaTypes.add(type.getJavaType()); ApiModel a = type.getJavaType().getAnnotation(ApiModel.class); if(null != a) { this.name = Strings.firstNotEmpty(a.name(), a.value(), this.name); this.description = Strings.firstNotEmpty(a.desc(), this.description); annotatedOnly = a.explicitProperties(); } } for (MProperty mp : type.getProperties()) { if(annotatedOnly) { BeanProperty bp = mp.getBeanProperty(); if(null != bp && !bp.isAnnotationPresent(ApiProperty.class)) { continue; } } addProperty(new MApiPropertyBuilder(mp)); } }