diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings index 0fd20ae4d11d116a71019418bb79c34f516ddb4f..5953cafef0856f6dc713176936e03590fad18c2c 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/.ratings @@ -1,2 +1,2 @@ -DerivedAnnotationBaseStaticImpl.java 60f0394ccbea9907c6f617c913bb844e84906e01 RED +DerivedAnnotationBaseStaticImpl.java 25b4a0b00fe68a1027ee81e52697e03988862373 YELLOW LibraryElementBaseStaticImpl.java 13222726153d5159994866795b059a4cc3522434 GREEN diff --git a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java index 60f0394ccbea9907c6f617c913bb844e84906e01..25b4a0b00fe68a1027ee81e52697e03988862373 100644 --- a/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java +++ b/org.fortiss.tooling.base/src/org/fortiss/tooling/base/model/base/impl/DerivedAnnotationBaseStaticImpl.java @@ -37,19 +37,20 @@ public class DerivedAnnotationBaseStaticImpl { * @return See above. */ public static <T> T getValue(IDerivedAnnotation<T> annotation) { - // TODO (SB): Compute derived annotated value only if user annotated value is not preferred. + T userAnnotatedValue = annotation.getUserAnnotatedValue(); + if(annotation.isUserAnnotatedValuePreferred() && userAnnotatedValue != null) { + // User annotated value is preferred and exists. + return userAnnotatedValue; + } + T derivedValue = annotation.getDerivedValue(); - if(annotation.isUserAnnotatedValuePreferred() || derivedValue == null) { - // User annotated value is preferred, or the derived value is not available - // --> return user annotated value - T userAnnotatedValue = annotation.getUserAnnotatedValue(); - if(userAnnotatedValue != null) { - // Only return the user annotated value if it is present, or a derived value is not - // present. - return userAnnotatedValue; - } + if(derivedValue != null) { + // User annotated value is not preferred: use the derived value. + return derivedValue; } - return derivedValue; + // Derived value does not exist: return the user annotated value, even if it is not + // preferred. If neither the derived or the user annotated values exist, we return null. + return userAnnotatedValue; } }