/** * Returns the referenced type name. */ public String getRefTypeName() { return type.isCollectionType() ? type.asCollectionType().getElementType().asTypeRef().getRefTypeName() : type.asTypeRef().getRefTypeName(); }
/** * Returns <code>true</code> if this type is a complex type of reference to a complex type. */ public boolean isComplexTypeOrRef() { return isComplexType() || (isTypeRef() && asTypeRef().getRefTypeKind() == MTypeKind.COMPLEX); }
@Override public boolean isComplexTypeCreatingOrCreated(Class type) { return null != getCreatingComplexType(type) || null != getCreatingComplexType(type); }
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 + "'"); }
private static boolean hasUnresolvedType(MType type) { if(type instanceof MUnresolvedTypeRef) { return true; } if(type.isCollectionType()) { return hasUnresolvedType(type.asCollectionType().getElementType()); } if(type.isDictionaryType()) { return hasUnresolvedType(type.asDictionaryType().getValueType()); } return false; }
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); }
/** * Returns the {@link MType} of the java type. * @param type required. * @param genericType optional. * @param context required. */ default MType getMType(Class<?> type, Type genericType, MTypeContext context) { return getMType(null, type, genericType, context); }
/** * Returns <code>true</code> if this type is a simple type. * * @see MSimpleType */ public boolean isSimpleType(){ return getTypeKind() == MTypeKind.SIMPLE; }
public boolean hasFacet(MSimpleTypeFacet facet){ for(MSimpleTypeFacet f : this.facets){ if(f.equals(facet)){ return true; } } return false; }
@Override public MTypeContainer create() { defaultFactory = new SimpleMTypeFactory(this); return this; }
@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); }
@Override public MType getMType(Class<?> type) { return getMType(type, null, context); }
/** * Returns the {@link MType} of the java type with default {@link MTypeContext}. */ default MType getMType(Class<?> type, Type genericType) { return getMType(type, genericType, MTypeContext.DEFAULT); }
/** * Returns true if this type is a void type. */ public boolean isVoidType() { return getTypeKind() == MTypeKind.VOID; }
/** * Returns the {@link MType} of the java type with default {@link MTypeContext}. */ default MType getMType(Class<?> declaringClass, Class<?> type, Type genericType) { return getMType(declaringClass, type, genericType, MTypeContext.DEFAULT); }
/** * Returns <code>true</code> if this type is a reference type. */ public boolean isTypeRef() { return getTypeKind() == MTypeKind.REFERENCE; }
/** * Returns true if this type is an object type. */ public boolean isObjectType() { return getTypeKind() == MTypeKind.OBJECT; }
/** * Returns <code>true</code> if this type is a collection type. */ public boolean isCollectionType(){ return getTypeKind() == MTypeKind.COLLECTION; }
/** * Returns <code>true</code> if this type is a complex type. */ public boolean isComplexType(){ return getTypeKind() == MTypeKind.COMPLEX; }