private void addCollectionDescriptor(MappingDescriptor mappingDescriptor, ClassDescriptor descriptor,
java.lang.reflect.Field field, Collection collectionAnnotation) {
Class targetClass = collectionAnnotation.elementClassName();
CollectionDescriptor collectionDescriptor = new CollectionDescriptor();
collectionDescriptor.setFieldName(field.getName());
if (collectionAnnotation.jcrName() != null && ! collectionAnnotation.jcrName().equals(""))
{
collectionDescriptor.setJcrName(collectionAnnotation.jcrName());
}
else
{
collectionDescriptor.setJcrName(field.getName());
}
Node annotationNode = (Node) targetClass.getAnnotation(Node.class);
collectionDescriptor.setProxy(collectionAnnotation.proxy());
collectionDescriptor.setAutoInsert(collectionAnnotation.autoInsert());
collectionDescriptor.setAutoRetrieve(collectionAnnotation.autoRetrieve());
collectionDescriptor.setAutoUpdate(collectionAnnotation.autoUpdate());
collectionDescriptor.setCollectionClassName(field.getType().getName());
if (! collectionAnnotation.elementClassName().equals(Object.class))
{
collectionDescriptor.setElementClassName(collectionAnnotation.elementClassName().getName());
}
else
{
setElementClassName(collectionDescriptor, field.getGenericType());
}
collectionDescriptor.setJcrElementName(collectionAnnotation.jcrElementName());
if (! collectionAnnotation.collectionClassName().equals(Object.class))
{
collectionDescriptor.setCollectionClassName(collectionAnnotation.collectionClassName().getName());
}
collectionDescriptor.setCollectionConverter(collectionAnnotation.collectionConverter().getName());
if (annotationNode != null)
{
collectionDescriptor.setJcrType(annotationNode.jcrType());
}
collectionDescriptor.setJcrSameNameSiblings(collectionAnnotation.jcrSameNameSiblings());
collectionDescriptor.setJcrAutoCreated(collectionAnnotation.jcrAutoCreated());
collectionDescriptor.setJcrProtected(collectionAnnotation.jcrProtected());
collectionDescriptor.setJcrOnParentVersion(collectionAnnotation.jcrOnParentVersion());
collectionDescriptor.setJcrMandatory(collectionAnnotation.jcrMandatory());
descriptor.addCollectionDescriptor(collectionDescriptor);
}