From 6dc6b30b7104636eb8bd39e8bd98bec7b3df9524 Mon Sep 17 00:00:00 2001 From: Alexander Diewald <diewald@fortiss.org> Date: Tue, 1 Oct 2019 14:56:46 +0200 Subject: [PATCH] YELLOW Issue-Ref: 3822 Issue-Url: https://af3-developer.fortiss.org/issues/3822 Signed-off-by: Alexander Diewald <diewald@fortiss.org> --- .../tooling/base/model/base/impl/.ratings | 2 +- .../impl/DerivedAnnotationBaseStaticImpl.java | 23 ++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) 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 0fd20ae4d..5953cafef 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 60f0394cc..25b4a0b00 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; } } -- GitLab