private ClassDescriptor buildClassDescriptor(MappingDescriptor mappingDescriptor, Class clazz) { ClassDescriptor classDescriptor = null; Node nodeAnnotation = (Node) clazz.getAnnotation(Node.class); if (nodeAnnotation != null) { classDescriptor = createClassDescriptor(clazz, nodeAnnotation); addImplementDescriptor(classDescriptor, clazz); addAttributeDescriptors(mappingDescriptor, classDescriptor, clazz); return classDescriptor; } else { throw new InitMapperException("The annotation @Node is not defined for the persistent class " + clazz.getName()); } }
/** * Add FieldDescriptors, BeanDescriptors and CollectionDescriptors. * The descriptots can be defined on the getter methods or on the field declation. * * @param mappingDescriptor The mapping descriptor * @param classDescriptor the classdescriptor for which the descriptors have to be added * @param clazz The associated class */ private void addAttributeDescriptors(MappingDescriptor mappingDescriptor, ClassDescriptor classDescriptor,Class clazz) { addDescriptorsFromFields(mappingDescriptor, classDescriptor, clazz); addDescriptorsFromGetters(mappingDescriptor, classDescriptor, clazz); }
private void addDescriptorsFromFields(MappingDescriptor mappingDescriptor, ClassDescriptor classDescriptor, Class clazz) { java.lang.reflect.Field[] fields = clazz.getDeclaredFields(); for (int index = 0; index < fields.length; index++) { Field fieldAnnotation = fields[index].getAnnotation(Field.class); if (fieldAnnotation != null) { addFieldDescriptor(classDescriptor, fields[index].getName(), fieldAnnotation); } // Check if there is an Bean annotation Bean beanAnnotation = fields[index].getAnnotation(Bean.class); if (beanAnnotation != null) { addBeanDescriptor(classDescriptor, fields[index].getName(), beanAnnotation); } // Check if there is an Collection annotation Collection collectionAnnotation = fields[index].getAnnotation(Collection.class); if (collectionAnnotation != null) { addCollectionDescriptor(mappingDescriptor, classDescriptor, fields[index], collectionAnnotation); } } }
public MappingDescriptor loadClassDescriptors() { MappingDescriptor mappingDescriptor = new MappingDescriptor(); for (Class clazz : annotatedClassNames) { ClassDescriptor classDescriptor = buildClassDescriptor(mappingDescriptor, clazz); mappingDescriptor.addClassDescriptor(classDescriptor); } return mappingDescriptor; }
public AnnotationMapperImpl(List<Class> annotatedClassNames) { descriptorReader = new AnnotationDescriptorReader(annotatedClassNames); this.buildMapper(); }
private void addDescriptorsFromFields(MappingDescriptor mappingDescriptor, ClassDescriptor classDescriptor, Class clazz) { java.lang.reflect.Field[] fields = clazz.getDeclaredFields(); for (int index = 0; index < fields.length; index++) { Field fieldAnnotation = fields[index].getAnnotation(Field.class); if (fieldAnnotation != null) { addFieldDescriptor(classDescriptor, fields[index].getName(), fieldAnnotation); } // Check if there is an Bean annotation Bean beanAnnotation = fields[index].getAnnotation(Bean.class); if (beanAnnotation != null) { addBeanDescriptor(classDescriptor, fields[index].getName(), beanAnnotation); } // Check if there is an Collection annotation Collection collectionAnnotation = fields[index].getAnnotation(Collection.class); if (collectionAnnotation != null) { addCollectionDescriptor(mappingDescriptor, classDescriptor, fields[index], collectionAnnotation); } } }
public MappingDescriptor loadClassDescriptors() { MappingDescriptor mappingDescriptor = new MappingDescriptor(); for (Class clazz : annotatedClassNames) { ClassDescriptor classDescriptor = buildClassDescriptor(mappingDescriptor, clazz); mappingDescriptor.addClassDescriptor(classDescriptor); } return mappingDescriptor; }
public AnnotationMapperImpl(List<Class> annotatedClassNames) { descriptorReader = new AnnotationDescriptorReader(annotatedClassNames); this.buildMapper(); }
addFieldDescriptor(classDescriptor, propertyDescriptor.getName(), fieldAnnotation); addBeanDescriptor(classDescriptor, propertyDescriptor.getName(), beanAnnotation); if (collectionAnnotation != null) { addCollectionDescriptor(mappingDescriptor, classDescriptor, propertyDescriptor.getPropertyType().getDeclaredField(propertyDescriptor.getName()), collectionAnnotation);
private ClassDescriptor buildClassDescriptor(MappingDescriptor mappingDescriptor, Class clazz) { ClassDescriptor classDescriptor = null; Node nodeAnnotation = (Node) clazz.getAnnotation(Node.class); if (nodeAnnotation != null) { classDescriptor = createClassDescriptor(clazz, nodeAnnotation); addImplementDescriptor(classDescriptor, clazz); addAttributeDescriptors(mappingDescriptor, classDescriptor, clazz); return classDescriptor; } else { throw new InitMapperException("The annotation @Node is not defined for the persistent class " + clazz.getName()); } }
/** * Add FieldDescriptors, BeanDescriptors and CollectionDescriptors. * The descriptots can be defined on the getter methods or on the field declation. * * @param mappingDescriptor The mapping descriptor * @param classDescriptor the classdescriptor for which the descriptors have to be added * @param clazz The associated class */ private void addAttributeDescriptors(MappingDescriptor mappingDescriptor, ClassDescriptor classDescriptor,Class clazz) { addDescriptorsFromFields(mappingDescriptor, classDescriptor, clazz); addDescriptorsFromGetters(mappingDescriptor, classDescriptor, clazz); }
addFieldDescriptor(classDescriptor, propertyDescriptor.getName(), fieldAnnotation); addBeanDescriptor(classDescriptor, propertyDescriptor.getName(), beanAnnotation); if (collectionAnnotation != null) { addCollectionDescriptor(mappingDescriptor, classDescriptor, propertyDescriptor.getPropertyType().getDeclaredField(propertyDescriptor.getName()), collectionAnnotation);