Skip to content
Snippets Groups Projects
Commit be7e5883 authored by Simon Barner's avatar Simon Barner
Browse files

setAnnotationValue(): Case distinction based on structural feature

* More stable than deciding based on provided value

Issue-Ref: 4092
Issue-Url: af3#4092



Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent 7df02a29
No related branches found
No related tags found
1 merge request!1474092: Implement a JFX controller for the creation and visualization of reference lists
This commit is part of merge request !147. Comments created here will be created in the context of that merge request.
AnnotationInstSpec.java 7a6cb55bfa9cafa9ead1f72089e554ee8142e8bf GREEN
DerivedAnnotationValueProviderBase.java afedd21d3469127bbb20adb34c191b5c9c980f6c GREEN
EStructuralFeatureDescriptor.java 169ece3fc0740c6ca1e5dde06a1be577d7cb9f80 YELLOW
EStructuralFeatureValueProviderBase.java 287facbbce47c16d892bae82a214f64ceeef2263 GREEN
EStructuralFeatureValueProviderBase.java 8dcecac16f8f654732ee0af7098443fe13ce1c85 YELLOW
IAnnotationValueProvider.java 08e0e5f66dc97865e9ac03e1ac646af332845e14 GREEN
ValueProviderBase.java e4e866840845346ec99a4304048f5327c4890996 GREEN
......@@ -16,6 +16,7 @@
package org.fortiss.tooling.base.annotation.valueprovider;
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.fortiss.tooling.kernel.utils.LoggingUtils.error;
import java.util.ArrayList;
......@@ -230,25 +231,29 @@ public abstract class EStructuralFeatureValueProviderBase<T extends IAnnotatedSp
}
setAnnotationValueFromString((String)value, specification);
} else if(value instanceof Collection<?>) {
Collection<?> collection = (Collection<?>)value;
if(collection.isEmpty()) {
specification.eSet(eStructuralFeature, emptyList());
} else {
if(collection.iterator().next() instanceof String) {
setAnnotationValueFromString((Collection<String>)value, specification);
} else {
if(eStructuralFeature.isMany()) {
Collection<?> collection = (value instanceof Collection<?>) ? (Collection<?>)value
: singletonList(value);
if(collection.isEmpty()) {
specification.eSet(eStructuralFeature, emptyList());
} else {
specification.eSet(eStructuralFeature, value);
if(collection.iterator().next() instanceof String) {
setAnnotationValueFromString((Collection<String>)collection, specification);
} else {
specification.eSet(eStructuralFeature, collection);
}
}
}
} else {
if(value != null) {
specification.eSet(eStructuralFeature, value);
} else {
// Treat 'null' as special value used to unset EStructural features. This
// implementation choice prevents to distinguish between 'null' and unset for
// EReferences).
specification.eUnset(eStructuralFeature);
if(value != null) {
specification.eSet(eStructuralFeature, value);
} else {
// Treat 'null' as special value used to unset EStructural features. This
// implementation choice prevents to distinguish between 'null' and unset for
// EReferences).
specification.eUnset(eStructuralFeature);
}
}
}
}
......
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