Community
Participate
Working Groups
the method TransientValueService.defaultValueIsSerializeable(EStructuralFeature) currently has this implementation: protected boolean defaultValueIsSerializeable(EStructuralFeature feature) { if (feature instanceof EAttribute) { if (feature.getEType() == EcorePackage.eINSTANCE.getEString() && feature.getDefaultValue() == null) return false; return true; } return false; } The assumption that any default value from an EAttribute can be serialized except if it's EString with value null - is far to narrow. A better strategy would be if(feature instanceof EAttribute) { return defaultVal != null || isJavaPrimitive(featureType) || isEnumLiteral(featureType) }
workaround: Subclass (Legacy)TransientValueService, override .defaultValueIsSerializeable() and bind it in the runtime module of your language.
> workaround isJavaPrimitive(featureType) OK as below? isEnumLiteral(featureType) how to? protected boolean defaultValueIsSerializeable(EStructuralFeature feature) { if(feature instanceof EAttribute) { EClassifier featureType = feature.getEType(); Object defaultValue = feature.getDefaultValue(); return defaultValue != null || isJavaPrimitive(featureType) || isEnumLiteral(featureType); } return false; } private boolean isJavaPrimitive(EClassifier eType) { return eType.getInstanceClass().isPrimitive(); } private boolean isEnumLiteral(EClassifier eType) { // TODO Not eType instanceof EEnumLiteral but ?? return false; }