Class scopeClass = element.getScopeClass();
if (scopeClass == javax.xml.bind.annotation.XmlElementDecl.GLOBAL.class){
scopeClass = JAXBElement.GlobalScope.class;
}
Class declaredType = helper.getClassForJavaClass(element.getJavaType());
JAXBElementConverter converter = new JAXBElementConverter(xmlField, declaredType, scopeClass);
if (isCollection){
XMLChoiceCollectionMapping xmlChoiceCollectionMapping = (XMLChoiceCollectionMapping) mapping;
Converter originalConverter = xmlChoiceCollectionMapping.getConverter(xmlField);
converter.setNestedConverter(originalConverter);
xmlChoiceCollectionMapping.addConverter(xmlField, converter);
} else {
XMLChoiceObjectMapping xmlChoiceObjectMapping = (XMLChoiceObjectMapping) mapping;
Converter originalConverter = xmlChoiceObjectMapping.getConverter(xmlField);
converter.setNestedConverter(originalConverter);
xmlChoiceObjectMapping.addConverter(xmlField, converter);
}
}
}
return mapping;