public static DecoratedTypeMirror mirrorOf(Callable<Class<?>> annotationValueFunction, DecoratedProcessingEnvironment env) { return mirrorOf(annotationValueFunction, env, null); }
public static DecoratedTypeMirror mirrorOf(Callable<Class<?>> annotationValueFunction, DecoratedProcessingEnvironment env) { return mirrorOf(annotationValueFunction, env, null); }
/** * The scope of the local element. * * @return The scope of the local element. */ public DecoratedTypeElement getElementScope() { DecoratedTypeElement declaration = null; DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return elementDecl.scope(); } }, this.env, XmlElementDecl.GLOBAL.class); if (typeMirror != null) { declaration = (DecoratedTypeElement) ((DeclaredType) typeMirror).asElement(); } return declaration; }
/** * The scope of the local element. * * @return The scope of the local element. */ public DecoratedTypeElement getElementScope() { DecoratedTypeElement declaration = null; DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return elementDecl.scope(); } }, this.env, XmlElementDecl.GLOBAL.class); if (typeMirror != null) { declaration = (DecoratedTypeElement) ((DeclaredType) typeMirror).asElement(); } return declaration; }
@Override public XmlType getBaseType() { XmlType xmlType = KnownXmlType.STRING; if (xmlEnum != null) { DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return xmlEnum.value(); } }, this.env); xmlType = XmlTypeFactory.getXmlType(typeMirror, this.context); } return xmlType; }
@Override public XmlType getBaseType() { XmlType xmlType = KnownXmlType.STRING; if (xmlEnum != null) { DecoratedTypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return xmlEnum.value(); } }, this.env); xmlType = XmlTypeFactory.getXmlType(typeMirror, this.context); } return xmlType; }
/** * The enum type containing the known qnames for this qname enum accessor, or null is this accessor doesn't reference a known qname type. * * @return The enum type containing the known qnames for this qname enum accessor. */ public DecoratedTypeMirror getQNameEnumRef() { final XmlQNameEnumRef enumRef = getAnnotation(XmlQNameEnumRef.class); DecoratedTypeMirror qnameEnumType = null; if (enumRef != null) { qnameEnumType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return enumRef.value(); } }, this.env); } return qnameEnumType; }
/** * The enum type containing the known qnames for this qname enum accessor, or null is this accessor doesn't reference a known qname type. * * @return The enum type containing the known qnames for this qname enum accessor. */ public DecoratedTypeMirror getQNameEnumRef() { final XmlQNameEnumRef enumRef = getAnnotation(XmlQNameEnumRef.class); DecoratedTypeMirror qnameEnumType = null; if (enumRef != null) { qnameEnumType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return enumRef.value(); } }, this.env); } return qnameEnumType; }
/** * The base type of an element accessor can be specified by an annotation. * * @return The base type. */ @Override public com.webcohesion.enunciate.modules.jaxb.model.types.XmlType getBaseType() { if (xmlElement != null) { TypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return xmlElement.type(); } }, this.env, XmlElement.DEFAULT.class); if (typeMirror != null) { return XmlTypeFactory.getXmlType(typeMirror, this.context); } } return super.getBaseType(); }
/** * The base type of an element accessor can be specified by an annotation. * * @return The base type. */ @Override public com.webcohesion.enunciate.modules.jaxb.model.types.XmlType getBaseType() { if (xmlElement != null) { TypeMirror typeMirror = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return xmlElement.type(); } }, this.env, XmlElement.DEFAULT.class); if (typeMirror != null) { return XmlTypeFactory.getXmlType(typeMirror, this.context); } } return super.getBaseType(); }
protected static AdapterType findAdapterType(DecoratedTypeMirror maybeContainedAdaptedType, Element referer, PackageElement pckg, EnunciateJaxbContext context) { DecoratedProcessingEnvironment env = context.getContext().getProcessingEnvironment(); TypeMirror adaptedType = TypeMirrorUtils.getComponentType(maybeContainedAdaptedType, env); adaptedType = adaptedType == null ? maybeContainedAdaptedType : adaptedType; 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) { return new AdapterType((DecoratedDeclaredType) adapterTypeMirror, context.getContext()); } } return null; }
protected static AdapterType findAdapterType(DecoratedTypeMirror maybeContainedAdaptedType, Element referer, PackageElement pckg, EnunciateJaxbContext context) { DecoratedProcessingEnvironment env = context.getContext().getProcessingEnvironment(); TypeMirror adaptedType = TypeMirrorUtils.getComponentType(maybeContainedAdaptedType, env); adaptedType = adaptedType == null ? maybeContainedAdaptedType : adaptedType; 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) { return new AdapterType((DecoratedDeclaredType) adapterTypeMirror, context.getContext()); } } return null; }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }
private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }
private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }
private String findSpecifiedTypeInfoValue(Member member, String specifiedType, TypeDefinition type) { if (type == null) { return null; } else if (type.getTypeIdType() == JsonTypeInfo.Id.NAME && member.getSimpleName().toString().equals(type.getTypeIdProperty())) { JsonSubTypes subTypes = type.getAnnotation(JsonSubTypes.class); if (subTypes != null) { for (final JsonSubTypes.Type element : subTypes.value()) { DecoratedTypeMirror choiceType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception { return element.value(); } }, type.getContext().getContext().getProcessingEnvironment()); if (choiceType.isInstanceOf(specifiedType)) { return element.name(); } } return null; } } JsonType supertype = type instanceof ObjectTypeDefinition ? ((ObjectTypeDefinition)type).getSupertype() : null; if (supertype instanceof JsonClassType) { return findSpecifiedTypeInfoValue(member, specifiedType, ((JsonClassType) supertype).getTypeDefinition()); } return null; }
specifiedType = Annotations.mirrorOf(new Callable<Class<?>>() { @Override public Class<?> call() throws Exception {