Search in sources :

Example 1 with JsonClassType

use of com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType in project enunciate by stoicflame.

the class ObjectDataTypeImpl method getSupertypes.

@Override
public List<DataTypeReference> getSupertypes() {
    ArrayList<DataTypeReference> supertypes = null;
    JsonType supertype = this.typeDefinition.getSupertype();
    while (supertype != null) {
        if (supertypes == null) {
            supertypes = new ArrayList<DataTypeReference>();
        }
        supertypes.add(new DataTypeReferenceImpl(supertype, registrationContext));
        supertype = supertype instanceof JsonClassType ? ((JsonClassType) supertype).getTypeDefinition() instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition) ((JsonClassType) supertype).getTypeDefinition()).getSupertype() : null : null;
    }
    return supertypes;
}
Also used : JsonType(com.webcohesion.enunciate.modules.jackson.model.types.JsonType) ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition) JsonClassType(com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType)

Example 2 with JsonClassType

use of com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType in project enunciate by stoicflame.

the class ObjectDataTypeImpl method gatherInterfaces.

private void gatherInterfaces(TypeElement clazz, Set<DataTypeReference> interfaces) {
    if (clazz == null) {
        return;
    }
    if (clazz.getQualifiedName().contentEquals(Object.class.getName())) {
        return;
    }
    List<? extends TypeMirror> ifaces = clazz.getInterfaces();
    for (TypeMirror iface : ifaces) {
        DecoratedTypeMirror decorated = (DecoratedTypeMirror) iface;
        decorated = this.typeDefinition.getContext().resolveSyntheticType(decorated);
        TypeDefinition typeDefinition = this.typeDefinition.getContext().findTypeDefinition(((DeclaredType) decorated).asElement());
        if (typeDefinition != null) {
            interfaces.add(new DataTypeReferenceImpl(new JsonClassType(typeDefinition), registrationContext));
        }
    }
    TypeMirror superclass = clazz.getSuperclass();
    if (superclass instanceof DeclaredType) {
        gatherInterfaces((TypeElement) ((DeclaredType) superclass).asElement(), interfaces);
    }
}
Also used : TypeMirror(javax.lang.model.type.TypeMirror) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) JsonClassType(com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType) TypeDefinition(com.webcohesion.enunciate.modules.jackson.model.TypeDefinition) ObjectTypeDefinition(com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition) DeclaredType(javax.lang.model.type.DeclaredType)

Example 3 with JsonClassType

use of com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType in project enunciate by stoicflame.

the class Member method getAccessorType.

/**
 * The type of an element accessor can be specified by an annotation.
 *
 * @return The accessor type.
 */
@Override
public DecoratedTypeMirror getAccessorType() {
    if (this.explicitType != null) {
        return this.explicitType;
    }
    JsonType specifiedJsonType = JsonTypeFactory.findSpecifiedType(this, this.context);
    DecoratedTypeMirror specifiedType = specifiedJsonType instanceof JsonClassType ? (DecoratedTypeMirror) ((JsonClassType) specifiedJsonType).getTypeDefinition().asType() : null;
    if (specifiedType != null) {
        return specifiedType;
    }
    return super.getAccessorType();
}
Also used : JsonType(com.webcohesion.enunciate.modules.jackson.model.types.JsonType) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) JsonClassType(com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType)

Aggregations

JsonClassType (com.webcohesion.enunciate.modules.jackson.model.types.JsonClassType)3 DecoratedTypeMirror (com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror)2 ObjectTypeDefinition (com.webcohesion.enunciate.modules.jackson.model.ObjectTypeDefinition)2 JsonType (com.webcohesion.enunciate.modules.jackson.model.types.JsonType)2 TypeDefinition (com.webcohesion.enunciate.modules.jackson.model.TypeDefinition)1 DeclaredType (javax.lang.model.type.DeclaredType)1 TypeMirror (javax.lang.model.type.TypeMirror)1