Search in sources :

Example 11 with DecoratedDeclaredType

use of com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType in project enunciate by stoicflame.

the class ComplexTypeExampleImpl method getDocumentationExampleTags.

private JavaDoc.JavaDocTagList getDocumentationExampleTags(Accessor member) {
    JavaDoc.JavaDocTagList tags = member.getJavaDoc().get("documentationExample");
    if (tags == null || tags.isEmpty()) {
        DecoratedTypeMirror accessorType = member.getBareAccessorType();
        if (accessorType instanceof DecoratedDeclaredType) {
            javax.lang.model.element.Element element = ((DecoratedDeclaredType) accessorType).asElement();
            tags = element instanceof DecoratedElement ? ((DecoratedElement) element).getJavaDoc().get("documentationExample") : null;
        }
    }
    return tags;
}
Also used : DecoratedDeclaredType(com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType) DecoratedElement(com.webcohesion.enunciate.javac.decorations.element.DecoratedElement) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) JavaDoc(com.webcohesion.enunciate.javac.javadoc.JavaDoc)

Example 12 with DecoratedDeclaredType

use of com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType in project enunciate by stoicflame.

the class SyntaxImpl method findDataTypeReference.

private DataTypeReference findDataTypeReference(DecoratedTypeMirror typeMirror) {
    if (typeMirror == null) {
        return null;
    }
    if (typeMirror.isInstanceOf(JAXBElement.class)) {
        List<? extends TypeMirror> typeArguments = ((DecoratedDeclaredType) typeMirror).getTypeArguments();
        typeMirror = TypeMirrorUtils.objectType(this.context.getContext().getProcessingEnvironment());
        if (typeArguments != null && !typeArguments.isEmpty()) {
            typeMirror = (DecoratedTypeMirror) typeArguments.get(0);
        }
    }
    XmlType xmlType;
    try {
        xmlType = XmlTypeFactory.getXmlType(typeMirror, this.context);
    } catch (Exception e) {
        xmlType = null;
    }
    return xmlType == null ? null : new DataTypeReferenceImpl(xmlType, typeMirror.isCollection() || typeMirror.isArray(), registrationContext);
}
Also used : DecoratedDeclaredType(com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType) XmlType(com.webcohesion.enunciate.modules.jaxb.model.types.XmlType)

Example 13 with DecoratedDeclaredType

use of com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType in project enunciate by stoicflame.

the class Accessor method getAccessorType.

/**
 * The type of the accessor.
 *
 * @return The type of the accessor.
 */
public DecoratedTypeMirror getAccessorType() {
    DecoratedTypeMirror accessorType = (DecoratedTypeMirror) asType();
    accessorType = OptionalUtils.stripOptional(accessorType, this.context.getContext().getProcessingEnvironment());
    DecoratedDeclaredType normalizedCollection = JAXBUtil.getNormalizedCollection(accessorType, this.context.getContext().getProcessingEnvironment());
    if (normalizedCollection != null) {
        accessorType = normalizedCollection;
    } else {
        MapType mapType = MapType.findMapType(accessorType, this.context);
        if (mapType != null) {
            accessorType = mapType;
        }
    }
    return accessorType;
}
Also used : DecoratedDeclaredType(com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) MapType(com.webcohesion.enunciate.modules.jaxb.model.util.MapType)

Example 14 with DecoratedDeclaredType

use of com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType in project enunciate by stoicflame.

the class JacksonUtil method findAdapterType.

private static AdapterType findAdapterType(DecoratedTypeMirror maybeContainedAdaptedType, Element referer, PackageElement pckg, EnunciateJackson1Context context) {
    if (context.isHonorJaxb()) {
        DecoratedProcessingEnvironment env = context.getContext().getProcessingEnvironment();
        TypeMirror adaptedType = TypeMirrorUtils.getComponentType(maybeContainedAdaptedType, env);
        final boolean isContained = adaptedType != null;
        adaptedType = isContained ? adaptedType : maybeContainedAdaptedType;
        XmlJavaTypeAdapter typeAdapterInfo = referer != null ? referer.getAnnotation(XmlJavaTypeAdapter.class) : null;
        if (adaptedType instanceof DeclaredType) {
            if (typeAdapterInfo == null) {
                typeAdapterInfo = ((DeclaredType) adaptedType).asElement().getAnnotation(XmlJavaTypeAdapter.class);
            }
            if ((typeAdapterInfo == null) && (pckg != null)) {
                TypeElement typeDeclaration = (TypeElement) ((DeclaredType) adaptedType).asElement();
                typeAdapterInfo = getAdaptersOfPackage(pckg, context).get(typeDeclaration.getQualifiedName().toString());
            }
        }
        if (typeAdapterInfo != null) {
            final XmlJavaTypeAdapter finalInfo = typeAdapterInfo;
            DecoratedTypeMirror adapterTypeMirror = Annotations.mirrorOf(new Callable<Class<?>>() {

                @Override
                public Class<?> call() throws Exception {
                    return finalInfo.value();
                }
            }, env);
            if (adapterTypeMirror instanceof DecoratedDeclaredType) {
                AdapterType adapterType = new AdapterType((DecoratedDeclaredType) adapterTypeMirror, context);
                if (!context.getContext().getProcessingEnvironment().getTypeUtils().isSameType(adapterType.getAdaptingType(), adaptedType)) {
                    return adapterType;
                }
            }
        }
    }
    return null;
}
Also used : DecoratedDeclaredType(com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType) TypeElement(javax.lang.model.element.TypeElement) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) XmlJavaTypeAdapter(javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter) AdapterType(com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType) DecoratedProcessingEnvironment(com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment) EnunciateException(com.webcohesion.enunciate.EnunciateException) TypeMirror(javax.lang.model.type.TypeMirror) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) DecoratedDeclaredType(com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType) DeclaredType(javax.lang.model.type.DeclaredType)

Example 15 with DecoratedDeclaredType

use of com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType in project enunciate by stoicflame.

the class DecoratedTypes method getDeclaredType.

public DeclaredType getDeclaredType(DeclaredType containing, TypeElement type, TypeMirror... typeArgs) {
    while (containing instanceof DecoratedDeclaredType) {
        containing = ((DecoratedDeclaredType) containing).getDelegate();
    }
    while (type instanceof DecoratedTypeElement) {
        type = ((DecoratedTypeElement) type).getDelegate();
    }
    TypeMirror[] copy = new TypeMirror[typeArgs.length];
    for (int i = 0; i < typeArgs.length; i++) {
        TypeMirror t = typeArgs[i];
        while (t instanceof DecoratedTypeMirror) {
            t = ((DecoratedTypeMirror) t).getDelegate();
        }
        copy[i] = t;
    }
    return delegate.getDeclaredType(containing, type, copy);
}
Also used : DecoratedTypeElement(com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement) DecoratedDeclaredType(com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror) DecoratedTypeMirror(com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror)

Aggregations

DecoratedDeclaredType (com.webcohesion.enunciate.javac.decorations.type.DecoratedDeclaredType)20 DecoratedTypeMirror (com.webcohesion.enunciate.javac.decorations.type.DecoratedTypeMirror)19 TypeElement (javax.lang.model.element.TypeElement)8 EnunciateException (com.webcohesion.enunciate.EnunciateException)5 DecoratedElement (com.webcohesion.enunciate.javac.decorations.element.DecoratedElement)5 DeclaredType (javax.lang.model.type.DeclaredType)5 Element (javax.lang.model.element.Element)4 TypeMirror (javax.lang.model.type.TypeMirror)4 DecoratedProcessingEnvironment (com.webcohesion.enunciate.javac.decorations.DecoratedProcessingEnvironment)3 JavaDoc (com.webcohesion.enunciate.javac.javadoc.JavaDoc)3 XmlJavaTypeAdapter (javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter)3 JsonSerialize (com.fasterxml.jackson.databind.annotation.JsonSerialize)1 Converter (com.fasterxml.jackson.databind.util.Converter)1 DecoratedTypeElement (com.webcohesion.enunciate.javac.decorations.element.DecoratedTypeElement)1 ReturnDocComment (com.webcohesion.enunciate.javac.javadoc.ReturnDocComment)1 AdapterType (com.webcohesion.enunciate.modules.jackson.model.adapters.AdapterType)1 MapType (com.webcohesion.enunciate.modules.jackson.model.util.MapType)1 AdapterType (com.webcohesion.enunciate.modules.jackson1.model.adapters.AdapterType)1 MapType (com.webcohesion.enunciate.modules.jackson1.model.util.MapType)1 AdapterType (com.webcohesion.enunciate.modules.jaxb.model.adapters.AdapterType)1