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, EnunciateJacksonContext context) {
DecoratedProcessingEnvironment env = context.getContext().getProcessingEnvironment();
TypeMirror adaptedType = TypeMirrorUtils.getComponentType(maybeContainedAdaptedType, env);
final boolean isContained = adaptedType != null;
adaptedType = isContained ? adaptedType : maybeContainedAdaptedType;
JsonSerialize serializationInfo = referer != null ? referer.getAnnotation(JsonSerialize.class) : null;
if (serializationInfo == null && adaptedType instanceof DeclaredType) {
serializationInfo = ((DeclaredType) adaptedType).asElement().getAnnotation(JsonSerialize.class);
}
if (serializationInfo != null) {
final JsonSerialize finalInfo = serializationInfo;
DecoratedTypeMirror adapterTypeMirror = Annotations.mirrorOf(new Callable<Class<?>>() {
@Override
public Class<?> call() throws Exception {
return isContained ? finalInfo.contentConverter() : finalInfo.converter();
}
}, env, Converter.None.class);
if (adapterTypeMirror instanceof DeclaredType) {
return new AdapterType((DeclaredType) adapterTypeMirror, context);
}
}
if (context.isHonorJaxb()) {
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) {
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 DataTypeExampleImpl method getDocumentationExampleTags.
private JavaDoc.JavaDocTagList getDocumentationExampleTags(Member member) {
JavaDoc.JavaDocTagList tags = member.getJavaDoc().get("documentationExample");
if (tags == null || tags.isEmpty()) {
DecoratedTypeMirror accessorType = member.getBareAccessorType();
if (accessorType instanceof DecoratedDeclaredType) {
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 DataTypeExampleImpl method getConfiguredExample.
private String getConfiguredExample(Member member) {
String configuredExample = null;
DecoratedTypeMirror accessorType = member.getBareAccessorType();
if (accessorType instanceof DecoratedDeclaredType) {
Element element = ((DecoratedDeclaredType) accessorType).asElement();
if (element instanceof TypeElement) {
configuredExample = member.getContext().lookupExternalExample((TypeElement) element);
}
}
return configuredExample;
}
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());
accessorType = this.context.resolveSyntheticType(accessorType);
DecoratedDeclaredType normalizedCollection = JacksonUtil.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 ComplexTypeExampleImpl method getConfiguredExample.
private String getConfiguredExample(Accessor member) {
String configuredExample = null;
DecoratedTypeMirror accessorType = member.getBareAccessorType();
if (accessorType instanceof DecoratedDeclaredType) {
javax.lang.model.element.Element element = ((DecoratedDeclaredType) accessorType).asElement();
if (element instanceof TypeElement) {
configuredExample = member.getContext().lookupExternalExample((TypeElement) element);
}
}
return configuredExample;
}
Aggregations