Skip to content

Commit 3abd579

Browse files
committed
fix: Fixed feature attributes
1 parent ba1222f commit 3abd579

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

  • plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl

‎plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttribute.java‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,16 @@ protected FeatureAttribute(IFeature feature, String name, T value, String unit,
8989
* @param oldAttribute The attribute to be copied
9090
* @param feature The feature to contain this attribute
9191
*/
92-
@SuppressWarnings("unchecked")
9392
protected FeatureAttribute(FeatureAttribute<T> oldAttribute, IFeature feature) {
9493
this.feature = feature;
95-
name = new String(oldAttribute.name);
96-
unit = new String(oldAttribute.unit);
97-
value = STRING.equals(oldAttribute.attributeType)
98-
? (T) new String((String)oldAttribute.value)
99-
: oldAttribute.value;
94+
// strings and the attribute values (String, Long, Double, Boolean) are immutable, so they can be shared;
95+
// this also copies attributes without value (e.g. a newly added string attribute has the value null)
96+
name = oldAttribute.name;
97+
unit = oldAttribute.unit;
98+
value = oldAttribute.value;
10099
recursive = oldAttribute.recursive;
101100
configureable = oldAttribute.configureable;
102-
attributeType = new String(oldAttribute.attributeType);
101+
attributeType = oldAttribute.attributeType;
103102
}
104103

105104
@Override

0 commit comments

Comments
 (0)