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 7faaf1e7907161eeb6e886641b6d3be7f6f886fa..20e8a8ac855498901f323fe53e0a18e9ebb97402 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 0b5a8e36f66c937b1659f0b73a0cf0428337e364 GREEN +DerivedAnnotationBaseStaticImpl.java d1b98d0c06b781fe297f63b0bfdc5dc72fe462c0 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 0b5a8e36f66c937b1659f0b73a0cf0428337e364..d1b98d0c06b781fe297f63b0bfdc5dc72fe462c0 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,21 +37,18 @@ public class DerivedAnnotationBaseStaticImpl { * @return See above. */ public static <T> T getValue(IDerivedAnnotation<T> annotation) { - T derivedValue = null; - if(annotation.getUserAnnotatedValue() != null) { - if(annotation.isUserAnnotatedValuePreferred()) { - // User annotated value is available and preferred -> return it - return annotation.getUserAnnotatedValue(); - } - derivedValue = annotation.getDerivedValue(); - if(derivedValue == null) { - // Derived value would be preferred, but it is not available -> return user - // annotated value - return annotation.getUserAnnotatedValue(); + 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; } } - // Use cached result of derived value if it is available - return derivedValue != null ? derivedValue : annotation.getDerivedValue(); + return derivedValue; } }