if (elems != null) {
result = new ArrayList<NamedType>();
for (XmlElement elem : elems.value()) {
String name = elem.name();
if (MARKER_FOR_DEFAULT.equals(name)) name = null;
result.add(new NamedType(elem.type(), name));
}
} else {
XmlElementRefs elemRefs = findAnnotation(XmlElementRefs.class, a, false, false, false);
if (elemRefs != null) {
result = new ArrayList<NamedType>();
for (XmlElementRef elemRef : elemRefs.value()) {
Class<?> refType = elemRef.type();
// only good for types other than JAXBElement (which is XML based)
if (!JAXBElement.class.isAssignableFrom(refType)) {
// [JACKSON-253] first consider explicit name declaration
String name = elemRef.name();
if (name == null || MARKER_FOR_DEFAULT.equals(name)) {
XmlRootElement rootElement = (XmlRootElement) refType.getAnnotation(XmlRootElement.class);
if (rootElement != null) {
name = rootElement.name();
}
}
if (name == null || MARKER_FOR_DEFAULT.equals(name)) {
name = Introspector.decapitalize(refType.getSimpleName());
}
result.add(new NamedType(refType, name));
}
}
}
}
// [Issue#1] check @XmlSeeAlso as well.
/* 17-Aug-2012, tatu: But wait! For structured type, what we really is
* value (content) type!
* If code below does not make full (or any) sense, do not despair -- it
* is wrong. Yet it works. The call sequence before we get here is mangled,
* its logic twisted... but as Dire Straits put it: "That ain't working --
* that's The Way You Do It!"
*/
XmlSeeAlso ann = a.getAnnotation(XmlSeeAlso.class);
if (ann != null) {
if (result == null) {
result = new ArrayList<NamedType>();
}
for (Class<?> cls : ann.value()) {
result.add(new NamedType(cls));
}
}
return result;
}