From 2e8738ddc0703a767b72f234f6104348b58e1f14 Mon Sep 17 00:00:00 2001 From: hoharri Date: Tue, 10 May 2011 10:13:13 +0000 Subject: [PATCH] Slight re-organization of code to prevent one unnecessary diagnostic message git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@20854 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../factories/RelatedValueRuleFactory.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedValueRuleFactory.java b/org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedValueRuleFactory.java index 37cd9812..828bb59f 100644 --- a/org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedValueRuleFactory.java +++ b/org.simantics.objmap/src/org/simantics/objmap/annotations/factories/RelatedValueRuleFactory.java @@ -33,12 +33,15 @@ import org.simantics.objmap.rules.range.IRangeAccessor; public class RelatedValueRuleFactory implements IFieldRuleFactory { @Override - public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, ValidationException, ServiceException { - RelatedValue annotation = (RelatedValue)_annotation; + public IMappingRule create(ReadGraph g, Annotation _annotation, Field field) throws ResourceNotFoundException, + ValidationException, ServiceException { + RelatedValue annotation = (RelatedValue) _annotation; Class adapterClass = annotation.adapter(); IRangeAccessor rangeAccessor = new FieldAccessor(field); - Resource valueType = DataTypeUtils.dataTypeOfClass(g, field.getType()); - if(adapterClass != IdentityAdapter.class) + Resource valueType; + if (adapterClass == IdentityAdapter.class) { + valueType = DataTypeUtils.dataTypeOfClass(g, field.getType()); + } else { try { ValueAdapter adapter = adapterClass.newInstance(); rangeAccessor = new AdaptedRangeAccessor(rangeAccessor, adapter); @@ -47,14 +50,9 @@ public class RelatedValueRuleFactory implements IFieldRuleFactory { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); - } - return new ValueRule( - new RelatedValueAccessor( - g.getResource(annotation.value()), - valueType - ), - rangeAccessor - ); + } + } + return new ValueRule(new RelatedValueAccessor(g.getResource(annotation.value()), valueType), rangeAccessor); } } -- 2.47.1