public class RelatedValueRuleFactory implements IFieldRuleFactory {\r
\r
@Override\r
- public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException {\r
- RelatedValue annotation = (RelatedValue)_annotation;\r
+ public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException,\r
+ ValidationException, ServiceException {\r
+ RelatedValue annotation = (RelatedValue) _annotation;\r
Class<? extends ValueAdapter> adapterClass = annotation.adapter();\r
IRangeAccessor<Object> rangeAccessor = new FieldAccessor<Object>(field);\r
- Resource valueType = DataTypeUtils.dataTypeOfClass(g, field.getType());\r
- if(adapterClass != IdentityAdapter.class)\r
+ Resource valueType;\r
+ if (adapterClass == IdentityAdapter.class) {\r
+ valueType = DataTypeUtils.dataTypeOfClass(g, field.getType());\r
+ } else {\r
try {\r
ValueAdapter adapter = adapterClass.newInstance();\r
rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter);\r
throw new RuntimeException(e);\r
} catch (IllegalAccessException e) {\r
throw new RuntimeException(e);\r
- } \r
- return new ValueRule(\r
- new RelatedValueAccessor(\r
- g.getResource(annotation.value()), \r
- valueType\r
- ),\r
- rangeAccessor\r
- );\r
+ }\r
+ }\r
+ return new ValueRule(new RelatedValueAccessor(g.getResource(annotation.value()), valueType), rangeAccessor);\r
}\r
\r
}\r