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;
}
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);
}
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;
}
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;
}
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);
}
Aggregations