Skip to content
Snippets Groups Projects
Commit ad57f4ef authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Simplify the retrieval of derived values

parent 181755cd
No related branches found
No related tags found
1 merge request!69DiagramEditors: Overwrite eclipse zoom class for fixed height
This commit is part of merge request !69. Comments created here will be created in the context of that merge request.
DerivedAnnotationBaseStaticImpl.java 0b5a8e36f66c937b1659f0b73a0cf0428337e364 GREEN DerivedAnnotationBaseStaticImpl.java d1b98d0c06b781fe297f63b0bfdc5dc72fe462c0 YELLOW
LibraryElementBaseStaticImpl.java 13222726153d5159994866795b059a4cc3522434 GREEN LibraryElementBaseStaticImpl.java 13222726153d5159994866795b059a4cc3522434 GREEN
...@@ -37,21 +37,18 @@ public class DerivedAnnotationBaseStaticImpl { ...@@ -37,21 +37,18 @@ public class DerivedAnnotationBaseStaticImpl {
* @return See above. * @return See above.
*/ */
public static <T> T getValue(IDerivedAnnotation<T> annotation) { public static <T> T getValue(IDerivedAnnotation<T> annotation) {
T derivedValue = null; T derivedValue = annotation.getDerivedValue();
if(annotation.getUserAnnotatedValue() != null) { if(annotation.isUserAnnotatedValuePreferred() || derivedValue == null) {
if(annotation.isUserAnnotatedValuePreferred()) { // User annotated value is preferred, or the derived value is not available
// User annotated value is available and preferred -> return it // --> return user annotated value
return annotation.getUserAnnotatedValue(); T userAnnotatedValue = annotation.getUserAnnotatedValue();
} if(userAnnotatedValue != null) {
derivedValue = annotation.getDerivedValue(); // Only return the user annotated value if it is present, or a derived value is not
if(derivedValue == null) { // present.
// Derived value would be preferred, but it is not available -> return user return userAnnotatedValue;
// annotated value
return annotation.getUserAnnotatedValue();
} }
} }
// Use cached result of derived value if it is available return derivedValue;
return derivedValue != null ? derivedValue : annotation.getDerivedValue();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment