private PropertyMetadata loadProperty(PropertyDescriptor propertyDescriptor) throws JasDBStorageException {
Method readMethod = propertyDescriptor.getReadMethod();
Method writeMethod = propertyDescriptor.getWriteMethod();
if(readMethod != null && writeMethod != null) {
Optional<JasDBProperty> readAnnotation = getOptionalAnnotation(readMethod, JasDBProperty.class);
Optional<JasDBProperty> writeAnnotation = getOptionalAnnotation(writeMethod, JasDBProperty.class);
Optional<Id> idAnnotation = getOptionalAnnotation(readMethod, Id.class);
if (readAnnotation.isPresent() || writeAnnotation.isPresent()) {
TypeMapper typeMapper = getTypeMapper(readMethod);
String propertyName = readAnnotation.isPresent() ? readAnnotation.get().name() : "";
propertyName = StringUtils.stringEmpty(propertyName) ? writeAnnotation.isPresent() ? writeAnnotation.get().name() : "" : propertyName;
propertyName = StringUtils.stringEmpty(propertyName) ? propertyDescriptor.getName() : propertyName;
boolean nullable = readAnnotation.isPresent() ? readAnnotation.get().nullable() : writeAnnotation.get().nullable();
LOG.debug("Found Entity property: {} nullable: {}", propertyDescriptor.getName(), nullable);
return new PropertyMetadataImpl(typeMapper, readMethod, writeMethod, propertyName, idAnnotation.isPresent(), nullable);
}
} else {
LOG.debug("Read or Write method not defined for property: {}", propertyDescriptor.getName());
}
return null;
}