use of com.predic8.membrane.annot.model.OtherAttributesInfo in project service-proxy by membrane.
the class HelpReference method handle.
private void handle(Model m, MainInfo main, ElementInfo ei) throws XMLStreamException {
xew.writeStartElement("element");
xew.writeAttribute("name", ei.getAnnotation().name());
if (ei.getAnnotation().mixed())
xew.writeAttribute("mixed", "true");
xew.writeAttribute("topLevel", Boolean.toString(ei.getAnnotation().topLevel()));
xew.writeAttribute("id", ei.getId());
if (!ei.getAnnotation().topLevel()) {
String primaryParentId = getPrimaryParentId(m, main, ei);
if (primaryParentId != null)
xew.writeAttribute("primaryParentId", primaryParentId);
}
handleDoc(ei);
List<AttributeInfo> ais = ei.getAis();
Collections.sort(ais, new Comparator<AttributeInfo>() {
@Override
public int compare(AttributeInfo o1, AttributeInfo o2) {
return o1.getXMLName().compareTo(o2.getXMLName());
}
});
OtherAttributesInfo oai = ei.getOai();
if (ais.size() > 0 && ais.get(0).getXMLName().equals("id"))
ais.remove(0);
if (ais.size() > 0 || oai != null) {
xew.writeStartElement("attributes");
for (AttributeInfo ai : ais) handle(ai);
if (oai != null) {
xew.writeStartElement("any");
handleDoc(oai);
xew.writeEndElement();
}
xew.writeEndElement();
}
List<ChildElementInfo> ceis = ei.getCeis();
if (ceis.size() > 0) {
xew.writeStartElement("children");
for (ChildElementInfo cei : ceis) handle(m, main, cei);
xew.writeEndElement();
}
xew.writeEndElement();
}
use of com.predic8.membrane.annot.model.OtherAttributesInfo in project service-proxy by membrane.
the class SpringConfigurationXSDGeneratingAnnotationProcessor method scan.
private void scan(Model m, MainInfo main, ElementInfo ii, TypeElement te) {
TypeMirror superclass = te.getSuperclass();
if (superclass instanceof DeclaredType)
scan(m, main, ii, (TypeElement) ((DeclaredType) superclass).asElement());
for (Element e2 : te.getEnclosedElements()) {
MCAttribute a = e2.getAnnotation(MCAttribute.class);
if (a != null) {
AttributeInfo ai = new AttributeInfo();
ai.setAnnotation(a);
ai.setE((ExecutableElement) e2);
ai.setRequired(isRequired(e2));
ii.getAis().add(ai);
ii.setHasIdField(ii.isHasIdField() || ai.getXMLName().equals("id"));
}
MCOtherAttributes d = e2.getAnnotation(MCOtherAttributes.class);
if (d != null) {
OtherAttributesInfo oai = new OtherAttributesInfo();
oai.setOtherAttributesSetter((ExecutableElement) e2);
ii.setOai(oai);
}
MCChildElement b = e2.getAnnotation(MCChildElement.class);
if (b != null) {
ChildElementInfo cei = new ChildElementInfo();
cei.setEi(ii);
cei.setAnnotation(b);
cei.setE((ExecutableElement) e2);
List<? extends VariableElement> parameters = cei.getE().getParameters();
if (parameters.size() == 0)
throw new ProcessingException("Setter must have exactly one parameter.", e2);
TypeMirror setterArgType = parameters.get(0).asType();
if (!(setterArgType instanceof DeclaredType))
throw new ProcessingException("Setter argument must be of an @MCElement-annotated type.", parameters.get(0));
cei.setTypeDeclaration((TypeElement) ((DeclaredType) setterArgType).asElement());
cei.setPropertyName(AnnotUtils.dejavaify(e2.getSimpleName().toString().substring(3)));
cei.setRequired(isRequired(e2));
ii.getCeis().add(cei);
// unwrap "java.util.List<?>" and "java.util.Collection<?>"
if (cei.getTypeDeclaration().getQualifiedName().toString().startsWith("java.util.List") || cei.getTypeDeclaration().getQualifiedName().toString().startsWith("java.util.Collection")) {
cei.setTypeDeclaration((TypeElement) ((DeclaredType) ((DeclaredType) setterArgType).getTypeArguments().get(0)).asElement());
cei.setList(true);
}
ChildElementDeclarationInfo cedi;
if (!main.getChildElementDeclarations().containsKey(cei.getTypeDeclaration())) {
cedi = new ChildElementDeclarationInfo();
cedi.setTarget(cei.getTypeDeclaration());
cedi.setRaiseErrorWhenNoSpecimen(!cei.getAnnotation().allowForeign());
main.getChildElementDeclarations().put(cei.getTypeDeclaration(), cedi);
} else {
cedi = main.getChildElementDeclarations().get(cei.getTypeDeclaration());
cedi.setRaiseErrorWhenNoSpecimen(cedi.isRaiseErrorWhenNoSpecimen() || !cei.getAnnotation().allowForeign());
}
cedi.addUsedBy(cei);
}
MCTextContent c = e2.getAnnotation(MCTextContent.class);
if (c != null) {
TextContentInfo tci = new TextContentInfo();
tci.setPropertyName(AnnotUtils.dejavaify(e2.getSimpleName().toString().substring(3)));
ii.setTci(tci);
}
}
HashSet<Integer> childOrders = new HashSet<Integer>();
for (ChildElementInfo cei : ii.getCeis()) {
if (!childOrders.add(cei.getAnnotation().order()))
throw new ProcessingException("@MCChildElement(order=...) must be unique.", cei.getE());
}
Collections.sort(ii.getCeis());
}
Aggregations