use of com.webcohesion.enunciate.javac.decorations.element.DecoratedElement in project enunciate by stoicflame.
the class Styles method gatherStyles.
/**
* Gather facets.
*
* @param declaration The declaration on which to gather facets.
* @return The facets gathered on the declaration.
*/
public static Set<String> gatherStyles(Element declaration, Map<String, String> annotationStyles) {
Set<String> bucket = new TreeSet<String>();
if (declaration != null) {
com.webcohesion.enunciate.metadata.Style style = declaration.getAnnotation(com.webcohesion.enunciate.metadata.Style.class);
if (style != null) {
bucket.add(style.value());
}
com.webcohesion.enunciate.metadata.Styles facets = declaration.getAnnotation(com.webcohesion.enunciate.metadata.Styles.class);
if (facets != null) {
for (com.webcohesion.enunciate.metadata.Style s : facets.value()) {
bucket.add(s.value());
}
}
List<? extends AnnotationMirror> annotationMirrors = declaration.getAnnotationMirrors();
for (AnnotationMirror annotationMirror : annotationMirrors) {
DeclaredType annotationType = annotationMirror.getAnnotationType();
if (annotationType != null) {
Element annotationDeclaration = annotationType.asElement();
if (annotationDeclaration instanceof TypeElement) {
String configuredStyle = annotationStyles.get(((TypeElement) annotationDeclaration).getQualifiedName().toString());
if (configuredStyle != null) {
bucket.add(configuredStyle);
}
}
style = annotationDeclaration.getAnnotation(com.webcohesion.enunciate.metadata.Style.class);
if (style != null) {
bucket.add(style.value());
}
facets = annotationDeclaration.getAnnotation(com.webcohesion.enunciate.metadata.Styles.class);
if (facets != null) {
for (com.webcohesion.enunciate.metadata.Style s : facets.value()) {
bucket.add(s.value());
}
}
}
}
if (declaration instanceof DecoratedElement) {
JavaDoc.JavaDocTagList styleTags = ((DecoratedElement) declaration).getJavaDoc().get("style");
if (styleTags != null) {
for (String styleTag : styleTags) {
bucket.add(styleTag);
}
}
}
}
return bucket;
}
use of com.webcohesion.enunciate.javac.decorations.element.DecoratedElement in project enunciate by stoicflame.
the class DecoratedElements method printElements.
@Override
public void printElements(Writer w, Element... elements) {
Element[] copy = new Element[elements.length];
for (int i = 0; i < elements.length; i++) {
Element e = elements[i];
while (e instanceof DecoratedElement) {
e = ((DecoratedElement) e).getDelegate();
}
copy[i] = e;
}
delegate.printElements(w, copy);
}
use of com.webcohesion.enunciate.javac.decorations.element.DecoratedElement 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.element.DecoratedElement 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.element.DecoratedElement in project enunciate by stoicflame.
the class Accessor method getXmlIDAccessor.
/**
* Gets the xml id accessor for the specified class type (recursively through superclasses).
*
* @param classType The class type.
* @return The xml id accessor.
*/
private DecoratedElement getXmlIDAccessor(DecoratedDeclaredType classType) {
if (classType == null) {
return null;
}
DecoratedTypeElement declaration = (DecoratedTypeElement) classType.asElement();
if ((declaration == null) || (Object.class.getName().equals(declaration.getQualifiedName().toString()))) {
return null;
}
for (VariableElement field : ElementFilter.fieldsIn(declaration.getEnclosedElements())) {
if (field.getAnnotation(XmlID.class) != null) {
return (DecoratedElement) field;
}
}
for (PropertyElement property : declaration.getProperties()) {
if (property.getAnnotation(XmlID.class) != null) {
return property;
}
}
TypeMirror superclass = declaration.getSuperclass();
if (superclass == null || superclass.getKind() == TypeKind.NONE) {
return null;
}
return getXmlIDAccessor((DecoratedDeclaredType) superclass);
}
Aggregations