{
List<Annotation> annotations = new ArrayList<Annotation>();
if (ammd.getPersistenceModifier() == FieldPersistenceModifier.NONE)
{
Annotation annotation = getAnnotationHandler(XmlTransient.class);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.hasExtension("XmlAttribute"))
{
Annotation annotation = getAnnotation(XmlAttribute.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.hasExtension("XmlElement"))
{
Annotation annotation = getAnnotation(XmlElement.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.hasExtension("XmlElementRef"))
{
Annotation annotation = getAnnotation(XmlElementRef.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.hasExtension("XmlElementWrapper"))
{
Annotation annotation = getAnnotation(XmlElementWrapper.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.hasExtension("XmlIDREF"))
{
Annotation annotation = getAnnotation(XmlIDREF.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.hasExtension("XmlID"))
{
Annotation annotation = getAnnotation(XmlID.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
else if (ammd.isPrimaryKey())
{
// All PK fields should have XmlID
// Note : JAXB has a limitation of 1 XmlID field per class!!
if (ammd.getAbstractClassMetaData().getNoOfPrimaryKeyMembers() > 1)
{
// TODO Remove this when we remove the limit on PK field numbers
throw new NucleusException("Class " + ammd.getAbstractClassMetaData().getFullClassName() + " has more than 1 primary key field - not valid for JAXB");
}
if (ammd.getAbstractClassMetaData().getNoOfPrimaryKeyMembers() == 1)
{
if (!String.class.isAssignableFrom(ammd.getType()))
{
// TODO Remove this when we remove the limit on PK field types
throw new NucleusException("Class " + ammd.getAbstractClassMetaData().getFullClassName() +
" has primary-key field " + ammd.getName() + " but this is not a String type - not valid for JAXB");
}
Annotation annotation = getAnnotation(XmlID.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}
}
else if (ammd.getEmbeddedMetaData() == null && ammd.getRelationType(clr) != Relation.NONE)
{
// Relation and not embedded so give it an XmlIDREF so we just refer to the other object(s)
Annotation annotation = getAnnotation(XmlIDREF.class, ammd, member, loc);
if (annotation != null)
{
annotations.add(annotation);
}
}