diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/AttributeUtils.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/AttributeUtils.java index a6cdc26118..cbe358ef97 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/AttributeUtils.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/AttributeUtils.java @@ -69,11 +69,11 @@ public class AttributeUtils { // return new String[] { "Not an extended Feature Model" }; // } - public static boolean isNumerical(IFeatureAttribute att) { + public static boolean isNumerical(IFeatureAttribute att) { return att.getType().equals(FeatureAttribute.LONG) || att.getType().equals(FeatureAttribute.DOUBLE); } - public static boolean isBoolean(IFeatureAttribute att) { + public static boolean isBoolean(IFeatureAttribute att) { return att.getType().equals(FeatureAttribute.BOOLEAN); } @@ -85,7 +85,7 @@ public static String getUnitByName(IFeatureModel featureModel, String attribute) IExtendedFeatureModel extModel = (IExtendedFeatureModel) featureModel; for (IFeature feat : extModel.getFeatures()) { IExtendedFeature ext = (IExtendedFeature) feat; - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (att.getName().equals(attribute)) { return att.getUnit(); } @@ -96,7 +96,7 @@ public static String getUnitByName(IFeatureModel featureModel, String attribute) return null; } - public static Double getDoubleValue(IFeatureAttribute att, Double defaultValue) { + public static Double getDoubleValue(IFeatureAttribute att, Double defaultValue) { if (!isNumerical(att)) { return null; } @@ -111,14 +111,14 @@ public static Double getDoubleValue(IFeatureAttribute att, Double defaultValue) } } - public static Boolean getBooleanValue(IFeatureAttribute att) { + public static Boolean getBooleanValue(IFeatureAttribute att) { if (!isBoolean(att) || att.getValue() == null) { return null; } return (boolean) att.getValue(); } - public static Double getBooleanValueAsDouble(IFeatureAttribute att, Double defaultValue) { + public static Double getBooleanValueAsDouble(IFeatureAttribute att, Double defaultValue) { Double trueDouble = 1d; Double falseDouble = 0d; Boolean value = getBooleanValue(att); @@ -136,7 +136,7 @@ public static Double getBooleanValueAsDouble(IFeatureAttribute att, Double defau * @param attributeName The name of the attribute * @return The attribute, or null if the feature or attribute cannot be found */ - public static IFeatureAttribute getAttribute(IFeatureModel featureModel, String featureName, String attributeName) { + public static IFeatureAttribute getAttribute(IFeatureModel featureModel, String featureName, String attributeName) { final IFeature feature = featureModel.getFeature(featureName); if (feature instanceof IExtendedFeature) { // Also checks that feature != null final IExtendedFeature extendedFeature = (IExtendedFeature) feature; @@ -153,13 +153,13 @@ public static IFeatureAttribute getAttribute(IFeatureModel featureModel, String * @param attributeName * @return The found attribute, or null if no attribute is found */ - public static IFeatureAttribute getChildAttribute(IExtendedFeature feature, String attributeName) { - IFeatureAttribute att = feature.getAttribute(attributeName); + public static IFeatureAttribute getChildAttribute(IExtendedFeature feature, String attributeName) { + IFeatureAttribute att = feature.getAttribute(attributeName); if (att != null) { return att; } for (IFeatureStructure child : feature.getStructure().getChildren()) { - IFeatureAttribute childAtt = getChildAttribute((IExtendedFeature) child.getFeature(), attributeName); + IFeatureAttribute childAtt = getChildAttribute((IExtendedFeature) child.getFeature(), attributeName); if (childAtt != null) { return childAtt; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/AbstractFeatureAttributeFactory.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/AbstractFeatureAttributeFactory.java index 3f6fc7a77b..785e3ffbe6 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/AbstractFeatureAttributeFactory.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/AbstractFeatureAttributeFactory.java @@ -22,6 +22,10 @@ import de.ovgu.featureide.fm.attributes.base.exceptions.FeatureAttributeParseException; import de.ovgu.featureide.fm.attributes.base.exceptions.UnknownFeatureAttributeTypeException; +import de.ovgu.featureide.fm.attributes.base.impl.BooleanFeatureAttribute; +import de.ovgu.featureide.fm.attributes.base.impl.DoubleFeatureAttribute; +import de.ovgu.featureide.fm.attributes.base.impl.LongFeatureAttribute; +import de.ovgu.featureide.fm.attributes.base.impl.StringFeatureAttribute; import de.ovgu.featureide.fm.core.base.IFeature; /** @@ -41,7 +45,7 @@ public abstract class AbstractFeatureAttributeFactory { * @return The instance of the feature attribute. Can return null when information contain invalid values. Like the value of an extended feature attribute * of type double is set to "test". */ - public abstract IFeatureAttribute createFeatureAttribute(IFeatureAttributeParsedData attributeData, IFeature correspondingFeature) + public abstract IFeatureAttribute createFeatureAttribute(IFeatureAttributeParsedData attributeData, IFeature correspondingFeature) throws FeatureAttributeParseException, UnknownFeatureAttributeTypeException; /** @@ -55,7 +59,7 @@ public abstract IFeatureAttribute createFeatureAttribute(IFeatureAttributeParsed * @param configurable true when the attribute should be configurable * @return The instance of the created feature attribute. */ - public abstract IFeatureAttribute createStringAttribute(IFeature correspondingFeature, String name, String unit, String value, boolean recursive, + public abstract StringFeatureAttribute createStringAttribute(IFeature correspondingFeature, String name, String unit, String value, boolean recursive, boolean configurable); /** @@ -69,7 +73,7 @@ public abstract IFeatureAttribute createStringAttribute(IFeature correspondingFe * @param configurable true when the attribute should be configurable * @return The instance of the created feature attribute. */ - public abstract IFeatureAttribute createBooleanAttribute(IFeature correspondingFeature, String name, String unit, Boolean value, boolean recursive, + public abstract BooleanFeatureAttribute createBooleanAttribute(IFeature correspondingFeature, String name, String unit, Boolean value, boolean recursive, boolean configurable); /** @@ -83,7 +87,7 @@ public abstract IFeatureAttribute createBooleanAttribute(IFeature correspondingF * @param configurable true when the attribute should be configurable * @return The instance of the created feature attribute. */ - public abstract IFeatureAttribute createLongAttribute(IFeature correspondingFeature, String name, String unit, Long value, boolean recursive, + public abstract LongFeatureAttribute createLongAttribute(IFeature correspondingFeature, String name, String unit, Long value, boolean recursive, boolean configurable); /** @@ -97,7 +101,7 @@ public abstract IFeatureAttribute createLongAttribute(IFeature correspondingFeat * @param configurable true when the attribute should be configurable * @return The instance of the created feature attribute. */ - public abstract IFeatureAttribute createDoubleAttribute(IFeature correspondingFeature, String name, String unit, Double value, boolean recursive, + public abstract DoubleFeatureAttribute createDoubleAttribute(IFeature correspondingFeature, String name, String unit, Double value, boolean recursive, boolean configurable); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IExtendedFeature.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IExtendedFeature.java index 41faf7be94..c01e934196 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IExtendedFeature.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IExtendedFeature.java @@ -38,14 +38,14 @@ public interface IExtendedFeature extends IFeature { /** * @return all attributes that are contained in this feature. */ - public List getAttributes(); + public List> getAttributes(); /** * @param name The name of an attribute * @return The attribute with the given name, or null if no such attribute exists */ - public default IFeatureAttribute getAttribute(String name) { - for (IFeatureAttribute attribute : getAttributes()) { + public default IFeatureAttribute getAttribute(String name) { + for (IFeatureAttribute attribute : getAttributes()) { if (attribute.getName().equals(name)) { return attribute; } @@ -56,17 +56,17 @@ public default IFeatureAttribute getAttribute(String name) { /** * @param attribute the attribute that is added to this feature. */ - public void addAttribute(IFeatureAttribute attribute); + public void addAttribute(IFeatureAttribute attribute); /** * @param attribute the attribute that needs to be removed from this feature. */ - public void removeAttribute(IFeatureAttribute attribute); + public void removeAttribute(IFeatureAttribute attribute); /** * @param attribute the attribute that needs to be checked for containment in this feature. * @return true, if the name of the given attribute is contained in the feature. False otherwise. */ - public boolean isContainingAttribute(IFeatureAttribute attribute); + public boolean isContainingAttribute(IFeatureAttribute attribute); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IFeatureAttribute.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IFeatureAttribute.java index 9b3a5f18f1..e573254021 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IFeatureAttribute.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/IFeatureAttribute.java @@ -31,7 +31,7 @@ * @author Joshua Sprey * @author Chico Sundermann */ -public interface IFeatureAttribute { +public interface IFeatureAttribute { /** * Retrieves the {@link IFeature} assigned to the feature attribute. @@ -53,7 +53,7 @@ public interface IFeatureAttribute { /** * @return The value of the feature attribute. */ - public Object getValue(); + public T getValue(); /** * @return The type of the feature attribute. @@ -94,7 +94,7 @@ public interface IFeatureAttribute { * * @param value New value for the attribute. */ - public void setValue(Object value); + public void setValue(T value); /** * Sets the feature attribute to recursive. @@ -133,7 +133,7 @@ public interface IFeatureAttribute { * @param feature New feature * @return Clone of attribute with new feature. */ - public IFeatureAttribute cloneRecursive(IFeature feature); + public IFeatureAttribute cloneRecursive(IFeature feature); /** * Clones the attribute. @@ -141,7 +141,7 @@ public interface IFeatureAttribute { * @param feature New feature * @return Clone of the attribute with the new feature. */ - public IFeatureAttribute cloneAtt(IFeature feature); + public IFeatureAttribute cloneAtt(IFeature feature); /** * @return true, if attribute is head recursive attribute. diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/BooleanFeatureAttribute.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/BooleanFeatureAttribute.java index 41100f0331..2c8e8a2006 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/BooleanFeatureAttribute.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/BooleanFeatureAttribute.java @@ -20,7 +20,6 @@ */ package de.ovgu.featureide.fm.attributes.base.impl; -import de.ovgu.featureide.fm.attributes.base.IFeatureAttribute; import de.ovgu.featureide.fm.core.base.IFeature; /** @@ -29,9 +28,7 @@ * @author Joshua Sprey * @author Chico Sundermann */ -public class BooleanFeatureAttribute extends FeatureAttribute { - - private Boolean value; +public class BooleanFeatureAttribute extends FeatureAttribute { /** * Creates a new boolean attribute with the given values. @@ -45,8 +42,7 @@ public class BooleanFeatureAttribute extends FeatureAttribute { * */ public BooleanFeatureAttribute(IFeature feature, String name, String unit, Boolean value, boolean recursive, boolean configurable) { - super(feature, name, unit, recursive, configurable); - this.value = value; + super(feature, name, value, unit, recursive, configurable); attributeType = FeatureAttribute.BOOLEAN; } @@ -58,27 +54,10 @@ public BooleanFeatureAttribute(IFeature feature, String name, String unit, Boole */ public BooleanFeatureAttribute(BooleanFeatureAttribute oldAttribute, IFeature feature) { super(oldAttribute, feature); - value = oldAttribute.value; - } - - @Override - public Boolean getValue() { - return value; } @Override - public void setValue(Object value) { - if (value == null) { - this.value = null; - return; - } - if (value instanceof Boolean) { - this.value = (Boolean) value; - } - } - - @Override - public IFeatureAttribute cloneAtt(IFeature feature) { + public BooleanFeatureAttribute cloneAtt(IFeature feature) { return new BooleanFeatureAttribute(this, feature); } @@ -89,7 +68,7 @@ public IFeatureAttribute cloneAtt(IFeature feature) { * @return clone of the attribute with value set to null */ @Override - public IFeatureAttribute cloneRecursive(IFeature feature) { + public BooleanFeatureAttribute cloneRecursive(IFeature feature) { return new BooleanFeatureAttribute(feature, this.getName(), this.getUnit(), null, this.isRecursive(), this.isConfigurable()); } @@ -97,4 +76,5 @@ public IFeatureAttribute cloneRecursive(IFeature feature) { public boolean isValidValue(String value) { return true; } + } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/DoubleFeatureAttribute.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/DoubleFeatureAttribute.java index 5729ed48ae..c4bdb4fc5a 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/DoubleFeatureAttribute.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/DoubleFeatureAttribute.java @@ -20,7 +20,6 @@ */ package de.ovgu.featureide.fm.attributes.base.impl; -import de.ovgu.featureide.fm.attributes.base.IFeatureAttribute; import de.ovgu.featureide.fm.core.base.IFeature; /** @@ -29,9 +28,7 @@ * @author Joshua Sprey * @author Chico Sundermann */ -public class DoubleFeatureAttribute extends FeatureAttribute { - - private Double value; +public class DoubleFeatureAttribute extends FeatureAttribute { /** * Creates a new double attribute with the given values. @@ -45,8 +42,7 @@ public class DoubleFeatureAttribute extends FeatureAttribute { * */ public DoubleFeatureAttribute(IFeature feature, String name, String unit, Double value, boolean recursive, boolean configurable) { - super(feature, name, unit, recursive, configurable); - this.value = value; + super(feature, name, value, unit, recursive, configurable); attributeType = FeatureAttribute.DOUBLE; } @@ -58,34 +54,13 @@ public DoubleFeatureAttribute(IFeature feature, String name, String unit, Double */ public DoubleFeatureAttribute(DoubleFeatureAttribute oldAttribute, IFeature feature) { super(oldAttribute, feature); - value = oldAttribute.value; - } - - @Override - public Double getValue() { - return value; - } - - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attributes.impl.FeatureAttribute#setValue(java.lang.Object) - */ - @Override - public void setValue(Object value) { - if (value == null) { - this.value = null; - return; - } - if (value instanceof Double) { - this.value = (Double) value; - } } /** * Returns a copy of the attribute */ @Override - public IFeatureAttribute cloneAtt(IFeature feature) { + public DoubleFeatureAttribute cloneAtt(IFeature feature) { return new DoubleFeatureAttribute(this, feature); } @@ -96,7 +71,7 @@ public IFeatureAttribute cloneAtt(IFeature feature) { * @return clone of the attribute with value set to null */ @Override - public IFeatureAttribute cloneRecursive(IFeature feature) { + public DoubleFeatureAttribute cloneRecursive(IFeature feature) { return new DoubleFeatureAttribute(feature, this.getName(), this.getUnit(), null, this.isRecursive(), this.isConfigurable()); } @@ -109,4 +84,5 @@ public boolean isValidValue(String value) { return false; } } + } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeature.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeature.java index 418970ac39..5ac6a77de7 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeature.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeature.java @@ -40,16 +40,16 @@ */ public class ExtendedFeature extends Feature implements IExtendedFeature { - protected List attributes; + protected List> attributes; public ExtendedFeature(IFeature oldFeature, IFeatureModel featureModel, boolean copyId, IFeatureStructure newFeatureStructure) { super(oldFeature, featureModel, copyId, newFeatureStructure); - attributes = Collections.synchronizedList(new LinkedList()); + attributes = Collections.synchronizedList(new LinkedList<>()); if (oldFeature instanceof IExtendedFeature) { // Copy attributes from the old feature if available IExtendedFeature feature = (IExtendedFeature) oldFeature; - for (IFeatureAttribute attribute : feature.getAttributes()) { + for (IFeatureAttribute attribute : feature.getAttributes()) { attributes.add(attribute.cloneAtt(this)); } } @@ -58,11 +58,11 @@ public ExtendedFeature(IFeature oldFeature, IFeatureModel featureModel, boolean public ExtendedFeature(IFeature oldFeature, IFeatureModel featureModel, boolean copyId) { super(oldFeature, featureModel, copyId); - attributes = Collections.synchronizedList(new LinkedList()); + attributes = Collections.synchronizedList(new LinkedList<>()); if (oldFeature instanceof IExtendedFeature) { // Copy attributes from the old feature if available IExtendedFeature feature = (IExtendedFeature) oldFeature; - for (IFeatureAttribute attribute : feature.getAttributes()) { + for (IFeatureAttribute attribute : feature.getAttributes()) { attributes.add(attribute.cloneAtt(this)); } } @@ -72,21 +72,21 @@ public ExtendedFeature(IFeatureModel featureModel, String name) { super(featureModel, name); // Create empty attributes list - attributes = Collections.synchronizedList(new LinkedList()); + attributes = Collections.synchronizedList(new LinkedList<>()); } @Override - public List getAttributes() { + public List> getAttributes() { return attributes; } @Override - public void addAttribute(IFeatureAttribute attribute) { + public void addAttribute(IFeatureAttribute attribute) { attributes.add(attribute); } @Override - public void removeAttribute(IFeatureAttribute attribute) { + public void removeAttribute(IFeatureAttribute attribute) { attributes.remove(attribute); } @@ -96,8 +96,8 @@ public IFeature clone(IFeatureModel newFeatureModel, boolean copyId, IFeatureStr } @Override - public boolean isContainingAttribute(IFeatureAttribute attribute) { - for (IFeatureAttribute att : attributes) { + public boolean isContainingAttribute(IFeatureAttribute attribute) { + for (IFeatureAttribute att : attributes) { if (attribute.getName().equals(att.getName())) { return true; } @@ -111,13 +111,13 @@ public String createTooltip(Object... objects) { return createExtendedTooltip(attributes, tooltip); } - public static String createExtendedTooltip(List attributes, StringBuilder tooltip) { + public static String createExtendedTooltip(List> attributes, StringBuilder tooltip) { tooltip.append("\n\n"); StringBuilder attributesString = new StringBuilder(); StringBuilder inhreritedString = new StringBuilder(); - List featureAttributes = new ArrayList<>(); - List inheritedAttributes = new ArrayList<>(); + List> featureAttributes = new ArrayList<>(); + List> inheritedAttributes = new ArrayList<>(); if (attributes.size() == 0) { tooltip.append("No Attributes.\n"); @@ -125,7 +125,7 @@ public static String createExtendedTooltip(List attributes, S attributesString.append("Attributes:\n"); inhreritedString.append("Inherited Attributes:\n"); for (int i = 0; i < attributes.size(); i++) { - IFeatureAttribute attribute = attributes.get(i); + IFeatureAttribute attribute = attributes.get(i); if (attributes.get(i).isRecursive() && !attributes.get(i).isHeadOfRecursiveAttribute()) { inheritedAttributes.add(attribute); } else { @@ -135,7 +135,7 @@ public static String createExtendedTooltip(List attributes, S // Append attributes defined for this feature for (int i = 0; i < featureAttributes.size(); i++) { - IFeatureAttribute iFeatureAttribute = featureAttributes.get(i); + IFeatureAttribute iFeatureAttribute = featureAttributes.get(i); if (iFeatureAttribute.isRecursive()) { attributesString.append("recursive "); } @@ -156,7 +156,7 @@ public static String createExtendedTooltip(List attributes, S // Append attributes inherited of this feature for (int i = 0; i < inheritedAttributes.size(); i++) { - IFeatureAttribute iFeatureAttribute = inheritedAttributes.get(i); + IFeatureAttribute iFeatureAttribute = inheritedAttributes.get(i); if (iFeatureAttribute.isRecursive()) { inhreritedString.append("recursive "); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeatureModelObfuscator.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeatureModelObfuscator.java index 5eaf025177..989d5f548f 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeatureModelObfuscator.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedFeatureModelObfuscator.java @@ -82,8 +82,8 @@ private void obfuscateStructure(IFeatureStructure orgFeatureStructure, IFeature final AbstractFeatureAttributeFactory attributeFactory = new FeatureAttributeFactory(); - for (IFeatureAttribute attribute : orgFeature.getAttributes()) { - IFeatureAttribute obfFeatureAttribute = null; + for (IFeatureAttribute attribute : orgFeature.getAttributes()) { + IFeatureAttribute obfFeatureAttribute = null; final String attributeName = attribute.getName(); final String obfAttributeName = getObfuscatedFeatureAttributeName(attributeName); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedMultiFeature.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedMultiFeature.java index baf5fdf846..a435deb756 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedMultiFeature.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/ExtendedMultiFeature.java @@ -40,23 +40,23 @@ */ public class ExtendedMultiFeature extends MultiFeature implements IExtendedFeature { - protected List attributes; + protected List> attributes; public ExtendedMultiFeature(IFeatureModel featureModel, String name) { super(featureModel, name); // Create empty attributes list - attributes = Collections.synchronizedList(new LinkedList()); + attributes = Collections.synchronizedList(new LinkedList<>()); } public ExtendedMultiFeature(IFeature oldFeature, IFeatureModel featureModel, boolean copyId, IFeatureStructure featureStructure) { super(oldFeature, featureModel, copyId, featureStructure); - attributes = Collections.synchronizedList(new LinkedList()); + attributes = Collections.synchronizedList(new LinkedList<>()); if (oldFeature instanceof IExtendedFeature) { // Copy attributes from the old feature if available IExtendedFeature feature = (IExtendedFeature) oldFeature; - for (IFeatureAttribute attribute : feature.getAttributes()) { + for (IFeatureAttribute attribute : feature.getAttributes()) { attributes.add(attribute.cloneAtt(this)); } } @@ -65,33 +65,33 @@ public ExtendedMultiFeature(IFeature oldFeature, IFeatureModel featureModel, boo public ExtendedMultiFeature(IFeature oldFeature, IFeatureModel featureModel, boolean copyId) { super(oldFeature, featureModel, copyId); - attributes = Collections.synchronizedList(new LinkedList()); + attributes = Collections.synchronizedList(new LinkedList<>()); if (oldFeature instanceof IExtendedFeature) { // Copy attributes from the old feature if available IExtendedFeature feature = (IExtendedFeature) oldFeature; - for (IFeatureAttribute attribute : feature.getAttributes()) { + for (IFeatureAttribute attribute : feature.getAttributes()) { attributes.add(attribute.cloneAtt(this)); } } } @Override - public List getAttributes() { + public List> getAttributes() { return attributes; } @Override - public void addAttribute(IFeatureAttribute attribute) { + public void addAttribute(IFeatureAttribute attribute) { attributes.add(attribute); } @Override - public void removeAttribute(IFeatureAttribute attribute) { + public void removeAttribute(IFeatureAttribute attribute) { attributes.remove(attribute); } @Override - public boolean isContainingAttribute(IFeatureAttribute attribute) { + public boolean isContainingAttribute(IFeatureAttribute attribute) { return attributes.stream().anyMatch(a -> attribute.getName().equals(a.getName())); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttribute.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttribute.java index 83a18974de..72415cc040 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttribute.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttribute.java @@ -20,8 +20,7 @@ */ package de.ovgu.featureide.fm.attributes.base.impl; -import java.util.HashMap; -import java.util.Map; +import java.util.Objects; import de.ovgu.featureide.fm.attributes.base.IExtendedFeature; import de.ovgu.featureide.fm.attributes.base.IFeatureAttribute; @@ -35,7 +34,7 @@ * @author Joshua Sprey * @author Chico Sundermann */ -public abstract class FeatureAttribute implements IFeatureAttribute { +public abstract class FeatureAttribute implements IFeatureAttribute { /** Identifier for double attributes */ public static final String DOUBLE = "double"; @@ -63,22 +62,22 @@ public abstract class FeatureAttribute implements IFeatureAttribute { */ protected String attributeType; - private Map savedRecursiveValues = new HashMap<>(); + protected T value; /** * Creates a new feature attribute with the given values. * * @param feature Assigned feature * @param name Name of the FeatureAttribute + * @param value Value of the FeatureAttribute * @param unit Unit of the FeatureAttribute * @param recursive True, if the current Attribute should be inherited * @param configureable True, if the current FeatureAttribute needs be seting the configuration. - * */ - protected FeatureAttribute(IFeature feature, String name, String unit, boolean recursive, boolean configureable) { - super(); + protected FeatureAttribute(IFeature feature, String name, T value, String unit, boolean recursive, boolean configureable) { this.feature = feature; this.name = name; + this.value = value; this.unit = unit; this.recursive = recursive; this.configureable = configureable; @@ -90,33 +89,24 @@ protected FeatureAttribute(IFeature feature, String name, String unit, boolean r * @param oldAttribute The attribute to be copied * @param feature The feature to contain this attribute */ - protected FeatureAttribute(FeatureAttribute oldAttribute, IFeature feature) { + @SuppressWarnings("unchecked") + protected FeatureAttribute(FeatureAttribute oldAttribute, IFeature feature) { this.feature = feature; - name = oldAttribute.name; - unit = oldAttribute.unit; + name = new String(oldAttribute.name); + unit = new String(oldAttribute.unit); + value = STRING.equals(oldAttribute.attributeType) + ? (T) new String((String)oldAttribute.value) + : oldAttribute.value; recursive = oldAttribute.recursive; configureable = oldAttribute.configureable; - attributeType = oldAttribute.attributeType; - - savedRecursiveValues = new HashMap<>(oldAttribute.savedRecursiveValues.size()); - for (Map.Entry e : oldAttribute.savedRecursiveValues.entrySet()) { - savedRecursiveValues.put(e.getKey(), e.getValue()); - } + attributeType = new String(oldAttribute.attributeType); } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#getName() - */ @Override public IFeature getFeature() { return feature; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#getName() - */ @Override public String getName() { if (name == null) { @@ -125,10 +115,6 @@ public String getName() { return name; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#getUnit() - */ @Override public String getUnit() { if (unit == null) { @@ -137,58 +123,31 @@ public String getUnit() { return unit; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#getValue() - */ - @Override - public abstract Object getValue(); - - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#isRecursive() - */ @Override public boolean isRecursive() { return recursive; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#getType() - */ @Override public String getType() { return attributeType; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#isConfigureable() - */ @Override public boolean isConfigurable() { return configureable; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#setName(java.lang.String) - */ @Override public void setFeature(IFeature feature) { this.feature = feature; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#setName(java.lang.String) - */ @Override public void setName(String name) { if (recursive) { for (IFeatureStructure struct : getFeature().getStructure().getChildren()) { - for (IFeatureAttribute att : ((IExtendedFeature) struct.getFeature()).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) struct.getFeature()).getAttributes()) { if (att.getName().equals(this.getName())) { att.setName(name); } @@ -198,16 +157,12 @@ public void setName(String name) { this.name = name; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#setUnit(java.lang.String) - */ @Override public void setUnit(String unit) { // recursive boolean is enough because otherwise it would not be clickable check this again later if (recursive) { for (IFeatureStructure struct : getFeature().getStructure().getChildren()) { - for (IFeatureAttribute att : ((IExtendedFeature) struct.getFeature()).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) struct.getFeature()).getAttributes()) { if (att.getName().equals(this.getName())) { att.setUnit(unit); } @@ -217,34 +172,16 @@ public void setUnit(String unit) { this.unit = unit; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#setValue(java.lang.String) - */ - @Override - public void setValue(Object value) { - - } - - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#setRecursive(boolean) - */ @Override public void setRecursive(boolean recursive) { this.recursive = recursive; } - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attribute.IFeatureAttribute#setConfigureable(boolean) - */ @Override public void setConfigurable(boolean configurable) { if (recursive) { - Iterable test = getFeature().getFeatureModel().getFeatures(); for (IFeatureStructure struct : getFeature().getStructure().getChildren()) { - for (IFeatureAttribute att : ((IExtendedFeature) struct.getFeature()).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) struct.getFeature()).getAttributes()) { if (att.getName().equals(this.getName())) { att.setConfigurable(configurable); } @@ -267,10 +204,7 @@ public void addRecursiveAttributes() { private void addRecursiveAttributes(IExtendedFeature feature) { for (IFeatureStructure childStructure : feature.getStructure().getChildren()) { IExtendedFeature child = (IExtendedFeature) childStructure.getFeature(); - IFeatureAttribute newAttribute = this.cloneRecursive(child); - if (savedRecursiveValues.containsKey(child)) { - newAttribute.setValue(savedRecursiveValues.get(child)); - } + IFeatureAttribute newAttribute = this.cloneRecursive(child); if (!child.isContainingAttribute(newAttribute)) { child.addAttribute(newAttribute); } @@ -291,9 +225,8 @@ public void deleteRecursiveAttributes() { private void deleteRecursiveAttributes(IExtendedFeature feature) { for (IFeatureStructure childStructure : feature.getStructure().getChildren()) { IExtendedFeature child = (IExtendedFeature) childStructure.getFeature(); - IFeatureAttribute att = child.getAttribute(getName()); + IFeatureAttribute att = child.getAttribute(getName()); if (att != null) { - saveRecursiveValue(child, att.getValue()); child.removeAttribute(att); } deleteRecursiveAttributes(child); @@ -308,15 +241,11 @@ public boolean isHeadOfRecursiveAttribute() { return true; } else { // Check parent feature/attribute if not root - IFeatureAttribute parentAttribute = ((IExtendedFeature) getFeature().getStructure().getParent().getFeature()).getAttribute(getName()); + IFeatureAttribute parentAttribute = ((IExtendedFeature) getFeature().getStructure().getParent().getFeature()).getAttribute(getName()); return parentAttribute == null || !parentAttribute.isRecursive(); } } - /* - * (non-Javadoc) - * @see java.lang.Object#toString() - */ @Override public String toString() { final StringBuilder builder = new StringBuilder(); @@ -325,11 +254,7 @@ public String toString() { builder.append(", Type: "); builder.append(attributeType); builder.append(", Value: "); - if (getValue() == null) { - builder.append("null"); - } else { - builder.append(getValue().toString()); - } + builder.append(String.valueOf(value)); builder.append(", Unit: "); builder.append(unit); builder.append(", Recursive: "); @@ -340,12 +265,27 @@ public String toString() { return builder.toString(); } - public void saveRecursiveValue(IExtendedFeature feature, Object value) { - savedRecursiveValues.put(feature, value); + public T getValue() { + return value; + } + + public void setValue(T value) { + this.value = (T) value; } - public Map getSavedRecursiveValues() { - return savedRecursiveValues; + @Override + public int hashCode() { + return Objects.hash(attributeType, configureable, feature, name, recursive, unit, value); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + FeatureAttribute other = (FeatureAttribute) obj; + return Objects.equals(attributeType, other.attributeType) && configureable == other.configureable && Objects.equals(feature, other.feature) + && Objects.equals(name, other.name) && recursive == other.recursive && Objects.equals(unit, other.unit) && Objects.equals(value, other.value); } } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttributeFactory.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttributeFactory.java index c2f664e0fd..00b40e1d4b 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttributeFactory.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/FeatureAttributeFactory.java @@ -38,7 +38,7 @@ public class FeatureAttributeFactory extends AbstractFeatureAttributeFactory { @Override - public IFeatureAttribute createFeatureAttribute(IFeatureAttributeParsedData attributeData, IFeature feature) + public IFeatureAttribute createFeatureAttribute(IFeatureAttributeParsedData attributeData, IFeature feature) throws FeatureAttributeParseException, UnknownFeatureAttributeTypeException { final Boolean configurable = Boolean.parseBoolean(attributeData.isConfigurable()); final Boolean recursive = Boolean.parseBoolean(attributeData.isRecursive()); @@ -77,24 +77,25 @@ public IFeatureAttribute createFeatureAttribute(IFeatureAttributeParsedData attr } @Override - public IFeatureAttribute createStringAttribute(IFeature correspondingFeature, String name, String unit, String value, boolean recursive, + public StringFeatureAttribute createStringAttribute(IFeature correspondingFeature, String name, String unit, String value, boolean recursive, boolean configurable) { return (new StringFeatureAttribute(correspondingFeature, name, unit, value, recursive, configurable)); } @Override - public IFeatureAttribute createBooleanAttribute(IFeature correspondingFeature, String name, String unit, Boolean value, boolean recursive, + public BooleanFeatureAttribute createBooleanAttribute(IFeature correspondingFeature, String name, String unit, Boolean value, boolean recursive, boolean configurable) { return (new BooleanFeatureAttribute(correspondingFeature, name, unit, value, recursive, configurable)); } @Override - public IFeatureAttribute createLongAttribute(IFeature correspondingFeature, String name, String unit, Long value, boolean recursive, boolean configurable) { + public LongFeatureAttribute createLongAttribute(IFeature correspondingFeature, String name, String unit, Long value, boolean recursive, + boolean configurable) { return (new LongFeatureAttribute(correspondingFeature, name, unit, value, recursive, configurable)); } @Override - public IFeatureAttribute createDoubleAttribute(IFeature correspondingFeature, String name, String unit, Double value, boolean recursive, + public DoubleFeatureAttribute createDoubleAttribute(IFeature correspondingFeature, String name, String unit, Double value, boolean recursive, boolean configurable) { return (new DoubleFeatureAttribute(correspondingFeature, name, unit, value, recursive, configurable)); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/LongFeatureAttribute.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/LongFeatureAttribute.java index e5fe973521..66652019b5 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/LongFeatureAttribute.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/LongFeatureAttribute.java @@ -20,7 +20,6 @@ */ package de.ovgu.featureide.fm.attributes.base.impl; -import de.ovgu.featureide.fm.attributes.base.IFeatureAttribute; import de.ovgu.featureide.fm.core.base.IFeature; /** @@ -29,9 +28,7 @@ * @author Joshua Sprey * @author Chico Sundermann */ -public class LongFeatureAttribute extends FeatureAttribute { - - private Long value; +public class LongFeatureAttribute extends FeatureAttribute { /** * Creates a new long attribute with the given values. @@ -45,8 +42,7 @@ public class LongFeatureAttribute extends FeatureAttribute { * */ public LongFeatureAttribute(IFeature feature, String name, String unit, Long value, boolean recursive, boolean configurable) { - super(feature, name, unit, recursive, configurable); - this.value = value; + super(feature, name, value, unit, recursive, configurable); attributeType = FeatureAttribute.LONG; } @@ -58,34 +54,13 @@ public LongFeatureAttribute(IFeature feature, String name, String unit, Long val */ public LongFeatureAttribute(LongFeatureAttribute oldAttribute, IFeature feature) { super(oldAttribute, feature); - value = oldAttribute.value; - } - - @Override - public Long getValue() { - return value; - } - - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attributes.impl.FeatureAttribute#setValue(java.lang.Object) - */ - @Override - public void setValue(Object value) { - if (value == null) { - this.value = null; - return; - } - if (value instanceof Long) { - this.value = (Long) value; - } } /** * Returns a copy of the attribute */ @Override - public IFeatureAttribute cloneAtt(IFeature feature) { + public LongFeatureAttribute cloneAtt(IFeature feature) { return new LongFeatureAttribute(this, feature); } @@ -96,17 +71,18 @@ public IFeatureAttribute cloneAtt(IFeature feature) { * @return clone of the attribute with value set to null */ @Override - public IFeatureAttribute cloneRecursive(IFeature feature) { - return new LongFeatureAttribute(feature, this.getName(), this.getUnit(), null, this.isRecursive(), this.isConfigurable()); + public LongFeatureAttribute cloneRecursive(IFeature feature) { + return new LongFeatureAttribute(feature, getName(), getUnit(), null, isRecursive(), isConfigurable()); } @Override public boolean isValidValue(String value) { try { - Long.parseLong(value.toString()); + Long.parseLong(value); return true; } catch (final NumberFormatException e) { return false; } } + } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/StringFeatureAttribute.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/StringFeatureAttribute.java index 9ca0dc28ba..428b285499 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/StringFeatureAttribute.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/base/impl/StringFeatureAttribute.java @@ -20,7 +20,6 @@ */ package de.ovgu.featureide.fm.attributes.base.impl; -import de.ovgu.featureide.fm.attributes.base.IFeatureAttribute; import de.ovgu.featureide.fm.core.base.IFeature; /** @@ -29,9 +28,7 @@ * @author Joshua Sprey * @author Chico Sundermann */ -public class StringFeatureAttribute extends FeatureAttribute { - - private String value; +public class StringFeatureAttribute extends FeatureAttribute { /** * Creates a new String attribute with the given values. @@ -45,8 +42,7 @@ public class StringFeatureAttribute extends FeatureAttribute { * */ public StringFeatureAttribute(IFeature feature, String name, String unit, String value, boolean recursive, boolean configurable) { - super(feature, name, unit, recursive, configurable); - this.value = value; + super(feature, name, value, unit, recursive, configurable); attributeType = FeatureAttribute.STRING; } @@ -58,32 +54,13 @@ public StringFeatureAttribute(IFeature feature, String name, String unit, String */ public StringFeatureAttribute(StringFeatureAttribute oldAttribute, IFeature feature) { super(oldAttribute, feature); - value = oldAttribute.value; - } - - @Override - public String getValue() { - return value; - } - - /* - * (non-Javadoc) - * @see de.ovgu.featureide.fm.core.attributes.impl.FeatureAttribute#setValue(java.lang.Object) - */ - @Override - public void setValue(Object value) { - if (value == null) { - this.value = null; - return; - } - this.value = value.toString(); } /** * Returns a copy of the attribute */ @Override - public IFeatureAttribute cloneAtt(IFeature feature) { + public StringFeatureAttribute cloneAtt(IFeature feature) { return new StringFeatureAttribute(this, feature); } @@ -94,7 +71,7 @@ public IFeatureAttribute cloneAtt(IFeature feature) { * @return clone of the attribute with value set to null */ @Override - public IFeatureAttribute cloneRecursive(IFeature feature) { + public StringFeatureAttribute cloneRecursive(IFeature feature) { return new StringFeatureAttribute(feature, this.getName(), this.getUnit(), null, this.isRecursive(), this.isConfigurable()); } @@ -102,4 +79,5 @@ public IFeatureAttribute cloneRecursive(IFeature feature) { public boolean isValidValue(String value) { return true; } + } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeComputationBundle.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeComputationBundle.java index 157c896e00..f69ff23003 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeComputationBundle.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeComputationBundle.java @@ -44,7 +44,7 @@ public boolean hasChildren() { @Override public List getChildren() { List children = new ArrayList<>(); - for (IFeatureAttribute att : getUniqueAttributes()) { + for (IFeatureAttribute att : getUniqueAttributes()) { children.add(new AttributeEntry(config, att)); } return children; @@ -64,11 +64,11 @@ public boolean supportsType(Object element) { return config.getFeatureModel() instanceof IExtendedFeatureModel; } - private List getUniqueAttributes() { - List attributeList = new ArrayList(); + private List> getUniqueAttributes() { + List> attributeList = new ArrayList>(); for (IFeature feat : config.getFeatureModel().getFeatures()) { if (feat instanceof IExtendedFeature) { - for (IFeatureAttribute att : ((IExtendedFeature) feat).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) feat).getAttributes()) { if (!containsAttribute(attributeList, att.getName())) { attributeList.add(att); } @@ -78,8 +78,8 @@ private List getUniqueAttributes() { return attributeList; } - private boolean containsAttribute(List list, String attributeName) { - for (IFeatureAttribute att : list) { + private boolean containsAttribute(List> list, String attributeName) { + for (IFeatureAttribute att : list) { if (att.getName().equals(attributeName)) { return true; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeEntry.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeEntry.java index 239058ab8c..fabba5fdd3 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeEntry.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/AttributeEntry.java @@ -20,11 +20,11 @@ public class AttributeEntry implements IOutlineEntry { private Configuration config; - private IFeatureAttribute attribute; + private IFeatureAttribute attribute; private final static String imgAttribute = "attribute_obj.ico"; - public AttributeEntry(Configuration config, IFeatureAttribute attribute) { + public AttributeEntry(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/CountAttributeComputation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/CountAttributeComputation.java index 0366bce251..cffe99de25 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/CountAttributeComputation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/CountAttributeComputation.java @@ -20,10 +20,10 @@ public class CountAttributeComputation implements IOutlineEntry { Configuration config; - IFeatureAttribute attribute; + IFeatureAttribute attribute; private static final String LABEL = "Number of occurences: "; - public CountAttributeComputation(Configuration config, IFeatureAttribute attribute) { + public CountAttributeComputation(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMaximumComputation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMaximumComputation.java index 2b9ffb02e6..bf170b8ad7 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMaximumComputation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMaximumComputation.java @@ -24,11 +24,11 @@ public class EstimatedMaximumComputation implements IOutlineEntry { private static final String LABEL = "Maximal sum of attribute value (est.): "; Configuration config; - IFeatureAttribute attribute; + IFeatureAttribute attribute; List selectedFeatures; List unselectedFeatures; - public EstimatedMaximumComputation(Configuration config, IFeatureAttribute attribute) { + public EstimatedMaximumComputation(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; } @@ -69,7 +69,7 @@ public boolean supportsType(Object element) { private double getSubtreeValue(IFeature root) { double value = 0; IExtendedFeature ext = (IExtendedFeature) root; - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (att.getName().equals(attribute.getName())) { if (att instanceof LongFeatureAttribute) { if (!(att.getValue() == null)) { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMinimumComputation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMinimumComputation.java index 10da1a5653..e08dfa611f 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMinimumComputation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/computations/impl/EstimatedMinimumComputation.java @@ -23,11 +23,11 @@ public class EstimatedMinimumComputation implements IOutlineEntry { private static final String LABEL = "Minimal sum of attribute value (est.): "; Configuration config; - IFeatureAttribute attribute; + IFeatureAttribute attribute; List selectedFeatures; List unselectedFeatures; - public EstimatedMinimumComputation(Configuration config, IFeatureAttribute attribute) { + public EstimatedMinimumComputation(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; } @@ -79,7 +79,7 @@ public void setConfig(Configuration config) { private double getSubtreeValue(IFeature root) { double value = 0; IExtendedFeature ext = (IExtendedFeature) root; - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (att.getName().equals(attribute.getName())) { if (att instanceof LongFeatureAttribute) { if (!(att.getValue() == null)) { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/config/ExtendedSelectableFeature.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/config/ExtendedSelectableFeature.java index d4e4c7edf3..7595e5a033 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/config/ExtendedSelectableFeature.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/config/ExtendedSelectableFeature.java @@ -51,7 +51,7 @@ public Map getConfigurableAttributes() { return configurableAttributes; } - public boolean hasAttributeWithConfiguredValue(IFeatureAttribute att) { + public boolean hasAttributeWithConfiguredValue(IFeatureAttribute att) { return configurableAttributes.containsKey(att.getName()); } @@ -63,7 +63,7 @@ public void addConfigurableAttribute(String name, String value) { configurableAttributes.put(name, value); } - public Object getAttributeValue(IFeatureAttribute att) { + public Object getAttributeValue(IFeatureAttribute att) { if (hasAttributeWithConfiguredValue(att)) { return configurableAttributes.get(att.getName()); } else { @@ -73,7 +73,7 @@ public Object getAttributeValue(IFeatureAttribute att) { public Object getAttributeDefaultValue(String attName) { IExtendedFeature feat = ((IExtendedFeature) getFeature()); - for (IFeatureAttribute att : feat.getAttributes()) { + for (IFeatureAttribute att : feat.getAttributes()) { if (att.getName().equals(attName)) { return att.getValue(); } @@ -89,7 +89,7 @@ public Object getAttributeValueByName(String attName) { } } - public void removeConfigurableAttribute(IFeatureAttribute att) { + public void removeConfigurableAttribute(IFeatureAttribute att) { if (hasAttributeWithConfiguredValue(att)) { configurableAttributes.remove(att.getName()); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/UVLExtendedFeatureModelFormat.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/UVLExtendedFeatureModelFormat.java index 44e6493cae..24c9c4f7b2 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/UVLExtendedFeatureModelFormat.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/UVLExtendedFeatureModelFormat.java @@ -184,7 +184,7 @@ protected Map> printAttributes(IFeature feature) { attributes.put(EXTENDED_ATTRIBUTE_NAME, new Attribute<>(EXTENDED_ATTRIBUTE_NAME, true)); } if (feature instanceof IExtendedFeature) { - for (IFeatureAttribute attr : ((IExtendedFeature) feature).getAttributes()) { + for (IFeatureAttribute attr : ((IExtendedFeature) feature).getAttributes()) { attributes.put(attr.getName(), new Attribute<>(attr.getName(), printAttribute(attr))); } @@ -199,7 +199,7 @@ protected Map> printAttributes(IFeature feature) { * @return the value of the attribute. This is either simply the value, if the attr has no other information, or a map containing all information of the * attribute. */ - private Object printAttribute(IFeatureAttribute attr) { + private Object printAttribute(IFeatureAttribute attr) { if (!attr.isConfigurable() && !attr.isRecursive() && (attr.getUnit() == null || attr.getUnit().equals("")) && attr.getValue() != null) { return attr.getValue(); } else { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/XmlExtendedFeatureModelFormat.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/XmlExtendedFeatureModelFormat.java index fe0e8b4466..1e6f8ae126 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/XmlExtendedFeatureModelFormat.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/format/XmlExtendedFeatureModelFormat.java @@ -104,8 +104,8 @@ protected void readDocument(Document doc, List warnings) throws Unsuppo throw new UnsupportedModelException(WRONG_SYNTAX, 1); } // handle recursive attributes - List recursiveAttributes = getRecursiveAttributes(); - for (IFeatureAttribute att : recursiveAttributes) { + List> recursiveAttributes = getRecursiveAttributes(); + for (IFeatureAttribute att : recursiveAttributes) { recurseAttributesWithLookup(att.getFeature(), att); } @@ -114,10 +114,10 @@ protected void readDocument(Document doc, List warnings) throws Unsuppo protected void createFeatureAttributes(Document doc, Element fnode, IFeature feature) { if (feature instanceof IExtendedFeature) { - List attributesList = ((IExtendedFeature) feature).getAttributes(); + List> attributesList = ((IExtendedFeature) feature).getAttributes(); if ((attributesList != null) && !attributesList.isEmpty()) { // Write FeatureAttributes into the XML - for (final IFeatureAttribute featureAttribute : attributesList) { + for (final IFeatureAttribute featureAttribute : attributesList) { final Element attributeNode; if (featureAttribute.isRecursive() && !featureAttribute.isHeadOfRecursiveAttribute()) { createRecursedAttribute(doc, fnode, featureAttribute); @@ -149,7 +149,7 @@ protected void createFeatureAttributes(Document doc, Element fnode, IFeature fea * @param fnode parent node * @param att recursed feature attribute that is supposed to be added */ - private void createRecursedAttribute(Document doc, Element fnode, IFeatureAttribute att) { + private void createRecursedAttribute(Document doc, Element fnode, IFeatureAttribute att) { final Element attributeNode = doc.createElement(XMLFeatureModelTags.ATTRIBUTE); if (att.getValue() == null) { return; @@ -242,7 +242,7 @@ protected void parseAttribute(IFeature parent, final Element element) throws Uns if (parsedAttribute.isRecursed()) { addLookUpEntry(parent.getName(), name, value); } else { - IFeatureAttribute featureAttribute; + IFeatureAttribute featureAttribute; try { featureAttribute = attributeFactory.createFeatureAttribute(parsedAttribute, parent); if (featureAttribute != null) { @@ -268,11 +268,11 @@ private void handleRecursiveAttributes() { // TODO Auto-generated method stub } - private List getRecursiveAttributes() { - List recursiveAttributes = new ArrayList<>(); + private List> getRecursiveAttributes() { + List> recursiveAttributes = new ArrayList<>(); for (IFeature feat : object.getFeatures()) { ExtendedFeature ext = (ExtendedFeature) feat; - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (att.isRecursive()) { recursiveAttributes.add(att); } @@ -281,8 +281,8 @@ private List getRecursiveAttributes() { return recursiveAttributes; } - private void recurseAttributesWithLookup(IFeature feature, IFeatureAttribute attribute) { - IFeatureAttribute newAttribute = null; + private void recurseAttributesWithLookup(IFeature feature, IFeatureAttribute attribute) { + IFeatureAttribute newAttribute = null; for (IFeatureStructure struct : feature.getStructure().getChildren()) { ExtendedFeature feat = (ExtendedFeature) struct.getFeature(); recurseAttributesWithLookup(feat, attribute); @@ -304,7 +304,8 @@ private String getValueFromLookup(String featName, String attributeName) { return null; } - private void addValueAccordingToType(IFeatureAttribute attribute, String value) { + @SuppressWarnings("unchecked") + private void addValueAccordingToType(IFeatureAttribute attribute, String value) { if (value == null) { return; } @@ -314,28 +315,28 @@ private void addValueAccordingToType(IFeatureAttribute attribute, String value) if (value != null) { valueBoolean = Boolean.parseBoolean(value); } - attribute.setValue(valueBoolean); + ((IFeatureAttribute) attribute).setValue(valueBoolean); break; case FeatureAttribute.LONG: Long valueLong = null; if (value != null) { valueLong = Long.parseLong(value); } - attribute.setValue(valueLong); + ((IFeatureAttribute) attribute).setValue(valueLong); break; case FeatureAttribute.DOUBLE: Double valueDouble = null; if (value != null) { valueDouble = Double.parseDouble(value); } - attribute.setValue(valueDouble); + ((IFeatureAttribute) attribute).setValue(valueDouble); break; case FeatureAttribute.STRING: String valueString = null; if (value != null) { valueString = value; } - attribute.setValue(valueString); + ((IFeatureAttribute) attribute).setValue(valueString); break; default: diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureNameValueProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureNameValueProvider.java index 5aea9fe5cb..de7efbc276 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureNameValueProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureNameValueProvider.java @@ -51,7 +51,7 @@ public Map getValues(Object obj, String[] values) { for (String key : keySet) { result.put(key, defaultValue); } - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (keySet.contains(att.getName())) { if (att.getType().equals(FeatureAttribute.BOOLEAN)) { result.put(att.getName(), AttributeUtils.getBooleanValueAsDouble(att, defaultValue)); @@ -70,7 +70,7 @@ public Map getUnits(Object obj, String[] values) { String name = (String) obj; IExtendedFeature ext = (IExtendedFeature) model.getFeature(name); Map result = new HashMap<>(); - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (keySet.contains(att.getName())) { result.put(att.getName(), att.getUnit()); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureValueProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureValueProvider.java index d3742d97cc..964e95f79d 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureValueProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/formula/provider/FeatureValueProvider.java @@ -51,7 +51,7 @@ public Map getValues(Object obj, String[] values) { for (String key : keySet) { result.put(key, DEFAULT_WEIGHT); } - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (keySet.contains(att.getName())) { if (att.getType().equals(FeatureAttribute.BOOLEAN)) { result.put(att.getName(), AttributeUtils.getBooleanValueAsDouble(att, defaultValue)); @@ -71,7 +71,7 @@ public Map getUnits(Object obj, String[] values) { Map result = new HashMap<>(); for (IFeature feat : model.getFeatures()) { IExtendedFeature ext = (IExtendedFeature) feat; - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { if (keySet.contains(att.getName())) { result.put(att.getName(), att.getUnit()); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeComputationBundle.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeComputationBundle.java index 05559963e9..9ef8aa3828 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeComputationBundle.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeComputationBundle.java @@ -64,7 +64,7 @@ public boolean hasChildren() { @Override public List getChildren() { List children = new ArrayList<>(); - for (IFeatureAttribute att : getUniqueAttributes()) { + for (IFeatureAttribute att : getUniqueAttributes()) { children.add(new AttributeEntry(config, att)); } return children; @@ -86,11 +86,11 @@ public boolean supportsType(Object element) { return isExtendedFeatureModel && isExtendedConfiguration; } - private List getUniqueAttributes() { - List attributeList = new ArrayList(); + private List> getUniqueAttributes() { + List> attributeList = new ArrayList<>(); for (IFeature feat : config.getFeatureModel().getFeatures()) { if (feat instanceof IExtendedFeature) { - for (IFeatureAttribute att : ((IExtendedFeature) feat).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) feat).getAttributes()) { if (!containsAttribute(attributeList, att.getName())) { attributeList.add(att); } @@ -100,8 +100,8 @@ private List getUniqueAttributes() { return attributeList; } - private boolean containsAttribute(List list, String attributeName) { - for (IFeatureAttribute att : list) { + private boolean containsAttribute(List> list, String attributeName) { + for (IFeatureAttribute att : list) { if (att.getName().equals(attributeName)) { return true; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeEntry.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeEntry.java index e893110bb7..6642104aa2 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeEntry.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeEntry.java @@ -40,11 +40,11 @@ public class AttributeEntry implements IOutlineEntry { private Configuration config; - private IFeatureAttribute attribute; + private IFeatureAttribute attribute; private final static String imgAttribute = "attribute_obj.ico"; - public AttributeEntry(Configuration config, IFeatureAttribute attribute) { + public AttributeEntry(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMaximumEntry.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMaximumEntry.java index 63296ac742..71118c2dfe 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMaximumEntry.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMaximumEntry.java @@ -33,7 +33,7 @@ public class AttributeMaximumEntry implements IOutlineEntry { - IFeatureAttribute attribute; + IFeatureAttribute attribute; Configuration config; Double result; EstimatedMaximumComputation estimatedMax; @@ -41,7 +41,7 @@ public class AttributeMaximumEntry implements IOutlineEntry { private static final String EST = " (est)"; private String labelSuffix; - public AttributeMaximumEntry(Configuration config, IFeatureAttribute attribute) { + public AttributeMaximumEntry(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; estimatedMax = new EstimatedMaximumComputation(config, attribute); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMinimumEntry.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMinimumEntry.java index 72b0e68971..c59408c480 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMinimumEntry.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/AttributeMinimumEntry.java @@ -33,7 +33,7 @@ public class AttributeMinimumEntry implements IOutlineEntry { - IFeatureAttribute attribute; + IFeatureAttribute attribute; Configuration config; EstimatedMinimumComputation estimatedMinimum; Double result; @@ -42,7 +42,7 @@ public class AttributeMinimumEntry implements IOutlineEntry { private static final String EST = " (est)"; private static final String LABEL = "Minimal sum of value: "; - public AttributeMinimumEntry(Configuration config, IFeatureAttribute attribute) { + public AttributeMinimumEntry(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; estimatedMinimum = new EstimatedMinimumComputation(config, attribute); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/CountAttributeComputation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/CountAttributeComputation.java index 30cef8d6ac..e408e1904c 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/CountAttributeComputation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/outlineentry/CountAttributeComputation.java @@ -40,10 +40,10 @@ public class CountAttributeComputation implements IOutlineEntry { Configuration config; - IFeatureAttribute attribute; + IFeatureAttribute attribute; private static final String LABEL = "Number of occurences: "; - public CountAttributeComputation(Configuration config, IFeatureAttribute attribute) { + public CountAttributeComputation(Configuration config, IFeatureAttribute attribute) { this.config = config; this.attribute = attribute; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMLabelProvider.java index 450198df72..1e52ce3756 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMLabelProvider.java @@ -29,7 +29,7 @@ public String getText(Object element) { return "UUups"; } if (element instanceof IFeatureAttribute) { - return ((IFeatureAttribute) element).getName(); + return ((IFeatureAttribute) element).getName(); } if (element instanceof ComputationHeader) { return ((ComputationHeader) element).getName(); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMTreeContentProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMTreeContentProvider.java index 4003cad5a1..18d8bd187f 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMTreeContentProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/statistics/ExtendedFMTreeContentProvider.java @@ -45,10 +45,10 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { @Override public Object[] getElements(Object inputElement) { if (fModel instanceof IExtendedFeatureModel) { - List attributeList = new ArrayList<>(); + List> attributeList = new ArrayList<>(); for (IFeature feat : fModel.getFeatures()) { if (feat instanceof IExtendedFeature) { - for (IFeatureAttribute att : ((IExtendedFeature) feat).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) feat).getAttributes()) { if (!containsAttribute(attributeList, att.getName())) { attributeList.add(att); } @@ -92,8 +92,8 @@ public boolean hasChildren(Object element) { return false; } - private boolean containsAttribute(List list, String attributeName) { - for (IFeatureAttribute att : list) { + private boolean containsAttribute(List> list, String attributeName) { + for (IFeatureAttribute att : list) { if (att.getName().equals(attributeName)) { return true; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeContentProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeContentProvider.java index 5fea97a829..25ee903ebe 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeContentProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeContentProvider.java @@ -124,7 +124,7 @@ public Object getParent(Object element) { final IExtendedFeature feature = (IExtendedFeature) element; return feature.getStructure().getParent() != null ? feature.getStructure().getParent().getFeature() : null; } else if (element instanceof IFeatureAttribute) { - return ((IFeatureAttribute) element).getFeature(); + return ((IFeatureAttribute) element).getFeature(); } return null; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeView.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeView.java index 19b12038fe..dc1a0a6489 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeView.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeView.java @@ -520,12 +520,12 @@ public void menuAboutToShow(IMenuManager manager) { menuManager.add(new AddFeatureAttributeAction(fmManager, featureName, FeatureAttribute.LONG, StringTable.ADD_LONG_ATTRIBUTE)); menuManager.add(new AddFeatureAttributeAction(fmManager, featureName, FeatureAttribute.DOUBLE, StringTable.ADD_DOUBLE_ATTRIBUTE)); } else { - List attributes = new ArrayList<>(); + List> attributes = new ArrayList<>(); for (final Object object : selection.toList()) { - if (!(object instanceof IFeatureAttribute)) { + if (!(object instanceof IFeatureAttribute)) { return; } else { - attributes.add((IFeatureAttribute) object); + attributes.add((IFeatureAttribute) object); } } menuManager.add(new RemoveFeatureAttributeAction(fmManager, attributes)); @@ -777,7 +777,7 @@ public void propertyChange(FeatureIDEEvent event) { } else if (event.getEventType() == EventType.FEATURE_ADD) { if (event.getSource() instanceof IExtendedFeatureModel) { IExtendedFeature feature = (IExtendedFeature) event.getNewValue(); - for (IFeatureAttribute att : ((IExtendedFeature) feature.getStructure().getParent().getFeature()).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) feature.getStructure().getParent().getFeature()).getAttributes()) { if (att.isRecursive()) { feature.addAttribute(att.cloneRecursive(feature)); } @@ -789,12 +789,12 @@ public void propertyChange(FeatureIDEEvent event) { GraphicalFeature graphFeat = (GraphicalFeature) event.getSource(); if (graphFeat.getObject() instanceof IExtendedFeature) { IExtendedFeature feat = (IExtendedFeature) graphFeat.getObject(); - for (IFeatureAttribute att : feat.getAttributes()) { + for (IFeatureAttribute att : feat.getAttributes()) { if (att.isRecursive() && !((IExtendedFeature) feat.getStructure().getParent().getFeature()).isContainingAttribute(att)) { feat.removeAttribute(att); } } - for (IFeatureAttribute att : ((IExtendedFeature) feat.getStructure().getParent().getFeature()).getAttributes()) { + for (IFeatureAttribute att : ((IExtendedFeature) feat.getStructure().getParent().getFeature()).getAttributes()) { if (att.isRecursive()) { if (!feat.isContainingAttribute(att)) { feat.addAttribute(att.cloneRecursive(feat)); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeViewSelectionFilter.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeViewSelectionFilter.java index fa9e8acff7..276f027c16 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeViewSelectionFilter.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/FeatureAttributeViewSelectionFilter.java @@ -133,12 +133,12 @@ private boolean filterConfiguration(Viewer viewer, Object parentElement, Object return false; } } else if (element instanceof IFeatureAttribute) { - return ((IFeatureAttribute) element).isConfigurable(); + return ((IFeatureAttribute) element).isConfigurable(); } return false; } - private boolean isConfigurableAttribute(IFeatureAttribute att) { + private boolean isConfigurableAttribute(IFeatureAttribute att) { return att.isConfigurable(); } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/actions/RemoveFeatureAttributeAction.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/actions/RemoveFeatureAttributeAction.java index cb5528652d..8fd449898a 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/actions/RemoveFeatureAttributeAction.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/actions/RemoveFeatureAttributeAction.java @@ -41,9 +41,9 @@ public class RemoveFeatureAttributeAction extends Action { private final IFeatureModelManager fmManager; - private final List attributes; + private final List> attributes; - public RemoveFeatureAttributeAction(IFeatureModelManager fmManager, List attributes) { + public RemoveFeatureAttributeAction(IFeatureModelManager fmManager, List> attributes) { super(StringTable.REMOVE_SELECTED_ATTRIBUTE); this.fmManager = fmManager; this.attributes = attributes; diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/AbstractFeatureAttributeEditingSupport.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/AbstractFeatureAttributeEditingSupport.java index 45b7c9fe3b..85ef7a4cb7 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/AbstractFeatureAttributeEditingSupport.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/AbstractFeatureAttributeEditingSupport.java @@ -65,7 +65,7 @@ public AbstractFeatureAttributeEditingSupport(ColumnViewer viewer) { protected boolean canEdit(Object element) { if (enabled && view.getCurrentEditor() instanceof FeatureModelEditor) { if (element instanceof IFeatureAttribute) { - IFeatureAttribute att = (IFeatureAttribute) element; + IFeatureAttribute att = (IFeatureAttribute) element; if (att.isRecursive() && !att.isHeadOfRecursiveAttribute()) { return false; } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeConfigureableEditingSupport.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeConfigureableEditingSupport.java index 6b44cface5..2e387abd1e 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeConfigureableEditingSupport.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeConfigureableEditingSupport.java @@ -69,7 +69,7 @@ protected CellEditor getCellEditor(Object element) { */ @Override protected Object getValue(Object element) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.isConfigurable(); } @@ -79,7 +79,7 @@ protected Object getValue(Object element) { */ @Override protected void setValue(Object element, Object value) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; FeatureModelOperationWrapper.run(new ChangeAttributeConfigurableOperation((IFeatureModelManager) view.getManager(), attribute, (Boolean) value)); } } diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeNameEditingSupport.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeNameEditingSupport.java index f1213e348a..9f7efc16ae 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeNameEditingSupport.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeNameEditingSupport.java @@ -59,13 +59,13 @@ protected CellEditor getCellEditor(Object element) { @Override protected Object getValue(Object element) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.getName(); } @Override protected void setValue(Object element, Object value) { - IFeatureAttribute attribute = (IFeatureAttribute) element; + IFeatureAttribute attribute = (IFeatureAttribute) element; IExtendedFeature feature = (IExtendedFeature) attribute.getFeature(); String newName = value.toString(); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeRecursiveEditingSupport.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeRecursiveEditingSupport.java index 0d21f090b3..fc02dd98c0 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeRecursiveEditingSupport.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeRecursiveEditingSupport.java @@ -76,7 +76,7 @@ protected CellEditor getCellEditor(Object element) { */ @Override protected Object getValue(Object element) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.isRecursive(); } @@ -86,7 +86,7 @@ protected Object getValue(Object element) { */ @Override protected void setValue(Object element, Object value) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; final IFeature feature = attribute.getFeature(); final Boolean newRecursive = (Boolean) value; @@ -100,7 +100,7 @@ protected void setValue(Object element, Object value) { FeatureModelOperationWrapper.run(new ChangeAttributeRecursiveOperation((IFeatureModelManager) view.getManager(), attribute, newRecursive)); } - private boolean isNameUnique(IFeatureAttribute attribute, IFeature feature) { + private boolean isNameUnique(IFeatureAttribute attribute, IFeature feature) { for (IFeatureStructure struct : feature.getStructure().getChildren()) { final IExtendedFeature feat = (IExtendedFeature) struct.getFeature(); if (feat.isContainingAttribute(attribute)) { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeUnitEditingSupport.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeUnitEditingSupport.java index 2c4bf25e0e..bb5a068065 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeUnitEditingSupport.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeUnitEditingSupport.java @@ -59,7 +59,7 @@ protected CellEditor getCellEditor(Object element) { */ @Override protected Object getValue(Object element) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.getUnit(); } @@ -69,7 +69,7 @@ protected Object getValue(Object element) { */ @Override protected void setValue(Object element, Object value) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; final String newUnit = value.toString(); if (!attribute.getUnit().equals(newUnit)) { FeatureModelOperationWrapper.run(new ChangeAttributeUnitOperation((IFeatureModelManager) view.getManager(), attribute, newUnit)); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeValueEditingSupport.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeValueEditingSupport.java index 01f0ab261f..9d89bbd345 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeValueEditingSupport.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/editingsupports/FeatureAttributeValueEditingSupport.java @@ -62,7 +62,7 @@ public FeatureAttributeValueEditingSupport(FeatureAttributeView view, ColumnView @Override protected CellEditor getCellEditor(Object element) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; if (attribute.getType().equals(FeatureAttribute.BOOLEAN)) { String[] items = { "", "false", "true" }; ComboBoxViewerCellEditor cellEditor = new ComboBoxViewerCellEditor((Composite) getViewer().getControl(), SWT.READ_ONLY); @@ -77,7 +77,7 @@ protected CellEditor getCellEditor(Object element) { @Override protected Object getValue(Object element) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; if (view.getCurrentEditor() instanceof ConfigurationEditor) { Configuration config = ((ConfigurationEditor) view.getCurrentEditor()).getConfigurationManager().getVarObject(); for (SelectableFeature feat : config.getFeatures()) { @@ -102,7 +102,7 @@ protected Object getValue(Object element) { @Override protected void setValue(Object element, Object value) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; final String valueString = value == null || value.toString().equals("") ? null : value.toString(); if (view.getMode() == FeatureAttributeOperationMode.CONFIGURATION_EDITOR) { setValueInConfig(attribute, valueString); @@ -120,7 +120,7 @@ protected void setValue(Object element, Object value) { * @param attribute The configurable attribute * @param value The new configured attribute value */ - private void setValueInConfig(IFeatureAttribute attribute, String value) { + private void setValueInConfig(IFeatureAttribute attribute, String value) { if (value == null || attribute.isValidValue(value)) { final ConfigurationManager manager = (ConfigurationManager) view.getManager(); switch (attribute.getType()) { @@ -157,7 +157,7 @@ private void setValueInConfig(IFeatureAttribute attribute, String value) { * @param attribute The attribute to be edited * @param value The new attribute value */ - private void setValueInFeatureDiagram(IFeatureAttribute attribute, String value) { + private void setValueInFeatureDiagram(IFeatureAttribute attribute, String value) { if (value == null || attribute.isValidValue(value)) { final IFeatureModelManager manager = (IFeatureModelManager) view.getManager(); switch (attribute.getType()) { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeColumnLabelProvider.java index a9393d66c7..546ae27f67 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeColumnLabelProvider.java @@ -58,7 +58,7 @@ public FeatureAttributeColumnLabelProvider(HashMap cachedImages, @Override public Color getBackground(Object element) { if (element instanceof IFeatureAttribute) { - IFeatureAttribute attribute = (IFeatureAttribute) element; + IFeatureAttribute attribute = (IFeatureAttribute) element; IFeature feature = attribute.getFeature(); final FeatureColor featureColor = FeatureColorManager.getColor(feature); return ColorPalette.toSwtColor(featureColor); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeConfigureableColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeConfigureableColumnLabelProvider.java index ce5ceba278..a1f7d01079 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeConfigureableColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeConfigureableColumnLabelProvider.java @@ -47,7 +47,7 @@ public String getText(Object element) { @Override public Image getImage(Object element) { if (element instanceof IFeatureAttribute) { - if (((IFeatureAttribute) element).isConfigurable()) { + if (((IFeatureAttribute) element).isConfigurable()) { return cachedImages.get(FeatureAttributeView.checkboxEnabled); } else { return cachedImages.get(FeatureAttributeView.checkboxDisabled); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeNameColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeNameColumnLabelProvider.java index 7a4009c337..72d9577b37 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeNameColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeNameColumnLabelProvider.java @@ -45,7 +45,7 @@ public String getText(Object element) { if ((element instanceof IFeature) || (element instanceof String)) { return element.toString(); } else if (element instanceof IFeatureAttribute) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.getName(); } return "null"; @@ -56,7 +56,7 @@ public Image getImage(Object element) { if ((element instanceof IFeature) || (element instanceof String)) { return cachedImages.get(FeatureAttributeView.imgFeature); } else if (element instanceof IFeatureAttribute) { - if (((IFeatureAttribute) element).isRecursive()) { + if (((IFeatureAttribute) element).isRecursive()) { return cachedImages.get(FeatureAttributeView.imgAttributeRecurisve); } else { return cachedImages.get(FeatureAttributeView.imgAttribute); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeRecursiveColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeRecursiveColumnLabelProvider.java index f499049055..45a6feb9e5 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeRecursiveColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeRecursiveColumnLabelProvider.java @@ -47,7 +47,7 @@ public String getText(Object element) { @Override public Image getImage(Object element) { if (element instanceof IFeatureAttribute) { - if (((IFeatureAttribute) element).isRecursive()) { + if (((IFeatureAttribute) element).isRecursive()) { return cachedImages.get(FeatureAttributeView.checkboxEnabled); } else { return cachedImages.get(FeatureAttributeView.checkboxDisabled); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeTypeColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeTypeColumnLabelProvider.java index 7d93ea9371..a17d806248 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeTypeColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeTypeColumnLabelProvider.java @@ -45,7 +45,7 @@ public String getText(Object element) { if ((element instanceof IFeature) || (element instanceof String)) { return "-"; } else if (element instanceof IFeatureAttribute) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.getType(); } return "null"; diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeUnitColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeUnitColumnLabelProvider.java index 7e0e6ee0d1..e526320856 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeUnitColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeUnitColumnLabelProvider.java @@ -45,7 +45,7 @@ public String getText(Object element) { if ((element instanceof IFeature) || (element instanceof String)) { return "-"; } else if (element instanceof IFeatureAttribute) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; return attribute.getUnit(); } return "null"; diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeValueColumnLabelProvider.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeValueColumnLabelProvider.java index c12d126638..ccf92b6586 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeValueColumnLabelProvider.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/labelprovider/FeatureAttributeValueColumnLabelProvider.java @@ -49,7 +49,7 @@ public String getText(Object element) { if ((element instanceof IFeature) || (element instanceof String)) { return "-"; } else if (element instanceof IFeatureAttribute) { - final IFeatureAttribute attribute = (IFeatureAttribute) element; + final IFeatureAttribute attribute = (IFeatureAttribute) element; if (view.getCurrentEditor() instanceof ConfigurationEditor) { Configuration config = ((ConfigurationEditor) view.getCurrentEditor()).getConfigurationManager().getVarObject(); for (SelectableFeature feat : config.getFeatures()) { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/AddFeatureAttributeOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/AddFeatureAttributeOperation.java index edfc31afbe..ea6047d553 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/AddFeatureAttributeOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/AddFeatureAttributeOperation.java @@ -71,7 +71,7 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { if (attributeName == null) { attributeName = getUniqueAttributeName(attributeType, extendedFeature); } - IFeatureAttribute attribute; + IFeatureAttribute attribute; switch (attributeType) { case FeatureAttribute.BOOLEAN: attribute = new BooleanFeatureAttribute(extendedFeature, attributeName, "", null, false, false); @@ -114,7 +114,7 @@ private String getUniqueAttributeName(String type, IExtendedFeature feature) { @Override protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { final IExtendedFeature extendedFeature = (IExtendedFeature) attribute.getFeature(); extendedFeature.removeAttribute(attribute); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeConfigurableOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeConfigurableOperation.java index 30fedb082e..27435c83ab 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeConfigurableOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeConfigurableOperation.java @@ -56,7 +56,7 @@ public class ChangeAttributeConfigurableOperation extends AbstractFeatureModelOp */ private final boolean oldConfigurable; - public ChangeAttributeConfigurableOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, boolean newConfigurable) { + public ChangeAttributeConfigurableOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, boolean newConfigurable) { super(featureModelManager, CHANGE_ATTRIBUTE_CONFIGURABLE_OPERATION_NAME); featureName = attribute.getFeature().getName(); attributeName = attribute.getName(); @@ -67,7 +67,7 @@ public ChangeAttributeConfigurableOperation(IFeatureModelManager featureModelMan @Override protected FeatureIDEEvent operation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setConfigurable(newConfigurable); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); @@ -77,7 +77,7 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { @Override protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setConfigurable(oldConfigurable); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeNameOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeNameOperation.java index 3f60424eb6..edc738b678 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeNameOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeNameOperation.java @@ -51,7 +51,7 @@ public class ChangeAttributeNameOperation extends AbstractFeatureModelOperation */ private final String newName; - public ChangeAttributeNameOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, String newName) { + public ChangeAttributeNameOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, String newName) { super(featureModelManager, CHANGE_ATTRIBUTE_NAME_OPERATION_NAME); featureName = attribute.getFeature().getName(); attributeName = attribute.getName(); @@ -60,7 +60,7 @@ public ChangeAttributeNameOperation(IFeatureModelManager featureModelManager, IF @Override protected FeatureIDEEvent operation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setName(newName); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); @@ -70,7 +70,7 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { @Override protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, newName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, newName); if (attribute != null) { attribute.setName(attributeName); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeRecursiveOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeRecursiveOperation.java index c9a45b9466..cbd15def27 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeRecursiveOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeRecursiveOperation.java @@ -56,7 +56,7 @@ public class ChangeAttributeRecursiveOperation extends AbstractFeatureModelOpera */ private final boolean oldRecursive; - public ChangeAttributeRecursiveOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, boolean newRecursive) { + public ChangeAttributeRecursiveOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, boolean newRecursive) { super(featureModelManager, CHANGE_ATTRIBUTE_RECURSIVE_OPERATION_NAME); featureName = attribute.getFeature().getName(); attributeName = attribute.getName(); @@ -71,7 +71,7 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { return FeatureIDEEvent.getDefault(EventType.FEATURE_ATTRIBUTE_CHANGED); } - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setRecursive(newRecursive); if (newRecursive) { @@ -90,7 +90,7 @@ protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { return FeatureIDEEvent.getDefault(EventType.FEATURE_ATTRIBUTE_CHANGED); } - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setRecursive(oldRecursive); if (oldRecursive) { diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeUnitOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeUnitOperation.java index 5af6e56a85..d9002de48d 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeUnitOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeUnitOperation.java @@ -56,7 +56,7 @@ public class ChangeAttributeUnitOperation extends AbstractFeatureModelOperation */ private final String oldUnit; - public ChangeAttributeUnitOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, String newUnit) { + public ChangeAttributeUnitOperation(IFeatureModelManager featureModelManager, IFeatureAttribute attribute, String newUnit) { super(featureModelManager, CHANGE_ATTRIBUTE_UNIT_OPERATION_NAME); featureName = attribute.getFeature().getName(); attributeName = attribute.getName(); @@ -67,7 +67,7 @@ public ChangeAttributeUnitOperation(IFeatureModelManager featureModelManager, IF @Override protected FeatureIDEEvent operation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setUnit(newUnit); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); @@ -77,7 +77,7 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { @Override protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setUnit(oldUnit); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeValueOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeValueOperation.java index 3950662eeb..7330a96361 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeValueOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeAttributeValueOperation.java @@ -56,18 +56,19 @@ public class ChangeAttributeValueOperation extends AbstractFeatureModelOperat /** * The old value of the attribute before the operation. */ - private Object oldValue; + private D oldValue; - public ChangeAttributeValueOperation(IFeatureModelManager fmManager, IFeatureAttribute att, D newValue) { + public ChangeAttributeValueOperation(IFeatureModelManager fmManager, IFeatureAttribute att, D newValue) { super(fmManager, CHANGE_ATTRIBUTE_VALUE_OPERATION_NAME); featureName = att.getFeature().getName(); attributeName = att.getName(); this.newValue = newValue; } + @SuppressWarnings("unchecked") @Override protected FeatureIDEEvent operation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = (IFeatureAttribute) AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { oldValue = attribute.getValue(); attribute.setValue(newValue); @@ -76,9 +77,10 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { return FeatureIDEEvent.getDefault(EventType.FEATURE_ATTRIBUTE_CHANGED); } + @SuppressWarnings("unchecked") @Override protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, featureName, attributeName); + final IFeatureAttribute attribute = (IFeatureAttribute) AttributeUtils.getAttribute(featureModel, featureName, attributeName); if (attribute != null) { attribute.setValue(oldValue); return new FeatureIDEEvent(attribute, EventType.FEATURE_ATTRIBUTE_CHANGED, true, attribute.getFeature()); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeConfigurableAttributeValueOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeConfigurableAttributeValueOperation.java index ae8eb5ffc5..ba2cf6cdd5 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeConfigurableAttributeValueOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/ChangeConfigurableAttributeValueOperation.java @@ -63,7 +63,7 @@ public class ChangeConfigurableAttributeValueOperation extends AbstractConfig */ private boolean firstOverwrite = true; - public ChangeConfigurableAttributeValueOperation(ConfigurationManager configurationManager, IFeatureAttribute att, D newValue) { + public ChangeConfigurableAttributeValueOperation(ConfigurationManager configurationManager, IFeatureAttribute att, D newValue) { super(configurationManager, CHANGE_CONFIGURABLE_ATTRIBUTE_VALUE_OPERATION_NAME); featureName = att.getFeature().getName(); attributeName = att.getName(); @@ -74,7 +74,7 @@ public ChangeConfigurableAttributeValueOperation(ConfigurationManager configurat protected FeatureIDEEvent operation(Configuration config) { final ExtendedConfiguration extConfig = (ExtendedConfiguration) config; final ExtendedSelectableFeature selectableFeat = extConfig.getSelectableFeature(featureName); - final IFeatureAttribute att = ((IExtendedFeature) selectableFeat.getFeature()).getAttribute(attributeName); + final IFeatureAttribute att = ((IExtendedFeature) selectableFeat.getFeature()).getAttribute(attributeName); firstOverwrite = !selectableFeat.hasAttributeWithConfiguredValue(att); oldValue = selectableFeat.getAttributeValue(att); if (newValue != null) { @@ -89,7 +89,7 @@ protected FeatureIDEEvent operation(Configuration config) { protected FeatureIDEEvent inverseOperation(Configuration config) { final ExtendedConfiguration extConfig = (ExtendedConfiguration) config; final ExtendedSelectableFeature selectableFeat = extConfig.getSelectableFeature(featureName); - final IFeatureAttribute att = ((IExtendedFeature) selectableFeat.getFeature()).getAttribute(attributeName); + final IFeatureAttribute att = ((IExtendedFeature) selectableFeat.getFeature()).getAttribute(attributeName); // Case: switch back to default value from model if (firstOverwrite) { selectableFeat.removeConfigurableAttribute(att); diff --git a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/RemoveFeatureAttributeOperation.java b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/RemoveFeatureAttributeOperation.java index e1f2c85ad5..088912d576 100644 --- a/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/RemoveFeatureAttributeOperation.java +++ b/plugins/de.ovgu.featureide.fm.attributes/src/de/ovgu/featureide/fm/attributes/view/operations/RemoveFeatureAttributeOperation.java @@ -70,13 +70,13 @@ public FeatureAttributeDescriptor(String featureName, String attributeName) { /** * Map of removed attributes and the names of their features. */ - private final Map removedAttributes; + private final Map, String> removedAttributes; - public RemoveFeatureAttributeOperation(IFeatureModelManager featureModelManager, List attributes) { + public RemoveFeatureAttributeOperation(IFeatureModelManager featureModelManager, List> attributes) { super(featureModelManager, REMOVE_ATTRIBUTE_OPERATION_NAME); this.attributes = new ArrayList<>(attributes.size()); - for (IFeatureAttribute a : attributes) { + for (IFeatureAttribute a : attributes) { this.attributes.add(new FeatureAttributeDescriptor(a.getFeature().getName(), a.getName())); } @@ -87,7 +87,8 @@ public RemoveFeatureAttributeOperation(IFeatureModelManager featureModelManager, protected FeatureIDEEvent operation(IFeatureModel featureModel) { removedAttributes.clear(); for (final FeatureAttributeDescriptor attributeDescriptor : attributes) { - final IFeatureAttribute attribute = AttributeUtils.getAttribute(featureModel, attributeDescriptor.featureName, attributeDescriptor.attributeName); + final IFeatureAttribute attribute = + AttributeUtils.getAttribute(featureModel, attributeDescriptor.featureName, attributeDescriptor.attributeName); if (attribute != null) { final IExtendedFeature extendedFeature = (IExtendedFeature) attribute.getFeature(); if (attribute.isRecursive()) { @@ -107,11 +108,11 @@ protected FeatureIDEEvent operation(IFeatureModel featureModel) { @Override protected FeatureIDEEvent inverseOperation(IFeatureModel featureModel) { - for (final Map.Entry removedAttribute : removedAttributes.entrySet()) { + for (final Map.Entry, String> removedAttribute : removedAttributes.entrySet()) { final IFeature feature = featureModel.getFeature(removedAttribute.getValue()); if (feature instanceof IExtendedFeature) { final IExtendedFeature extendedFeature = (IExtendedFeature) feature; - final IFeatureAttribute attribute = removedAttribute.getKey().cloneAtt(extendedFeature); + final IFeatureAttribute attribute = removedAttribute.getKey().cloneAtt(extendedFeature); extendedFeature.addAttribute(attribute); if (attribute.isRecursive()) { attribute.addRecursiveAttributes(); // Restores values of descendants diff --git a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/Renaming.java b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/Renaming.java index c3f857a13a..9501d71df8 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/Renaming.java +++ b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/Renaming.java @@ -20,6 +20,8 @@ */ package de.ovgu.featureide.fm.core; +import java.util.Objects; + /** * Representation of a feature renaming. */ @@ -34,4 +36,24 @@ public Renaming(String oldName, String newName) { this.newName = newName; } + @Override + public int hashCode() { + return Objects.hash(newName, oldName); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Renaming other = (Renaming) obj; + return Objects.equals(newName, other.newName) && Objects.equals(oldName, other.oldName); + } + } diff --git a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/RenamingsManager.java b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/RenamingsManager.java index 06704b72b7..fce52bccf6 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/RenamingsManager.java +++ b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/RenamingsManager.java @@ -25,6 +25,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import org.prop4j.Literal; @@ -204,4 +205,24 @@ public RenamingsManager clone(IFeatureModel newModel) { return new RenamingsManager(this, newModel); } + @Override + public int hashCode() { + return Objects.hash(renamings); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final RenamingsManager other = (RenamingsManager) obj; + return Objects.equals(renamings, other.renamings); + } + } diff --git a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureModel.java b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureModel.java index 88f1b0a556..32cccd498f 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureModel.java +++ b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureModel.java @@ -29,6 +29,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import org.prop4j.NodeWriter; @@ -57,6 +58,7 @@ * @author Stefan Krueger * @author Marcus Pinnecke */ + public class FeatureModel implements IFeatureModel { private static long NEXT_ID = 0; @@ -142,6 +144,18 @@ protected FeatureModel(FeatureModel oldFeatureModel, IFeature newRoot, boolean c } } } + + final LinkedHashMap temp = new LinkedHashMap<>(elements); + elements.clear(); + for (final Entry elementEntry : oldFeatureModel.elements.entrySet()) { + final Long key = elementEntry.getKey(); + final IFeatureModelElement value = elementEntry.getValue(); + if (value instanceof IFeature) { + elements.put(key, temp.get(key)); + } else if (value instanceof IConstraint) { + elements.put(key, value); + } + } } protected IFeatureModelProperty createProperty() { diff --git a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureProperty.java b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureProperty.java index ebed328a5c..2b1e356b95 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureProperty.java +++ b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureProperty.java @@ -20,6 +20,8 @@ */ package de.ovgu.featureide.fm.core.base.impl; +import java.util.Objects; + import de.ovgu.featureide.fm.core.base.IFeature; import de.ovgu.featureide.fm.core.base.IFeatureProperty; @@ -38,7 +40,7 @@ public class FeatureProperty implements IFeatureProperty { public FeatureProperty(FeatureProperty oldProperty, IFeature correspondingFeature) { this.correspondingFeature = correspondingFeature != null ? correspondingFeature : oldProperty.correspondingFeature; - description = oldProperty.description.toString(); + description = new String(oldProperty.description); implicit = oldProperty.implicit; } @@ -99,4 +101,24 @@ public boolean isImplicit() { public void setImplicit(boolean implicit) { this.implicit = implicit; } + + @Override + public int hashCode() { + return Objects.hash(description, implicit); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final FeatureProperty other = (FeatureProperty) obj; + return Objects.equals(description, other.description) && (implicit == other.implicit); + } } diff --git a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureStructure.java b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureStructure.java index ec2857a6f9..2f8021f039 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureStructure.java +++ b/plugins/de.ovgu.featureide.fm.core/src/de/ovgu/featureide/fm/core/base/impl/FeatureStructure.java @@ -24,6 +24,7 @@ import java.util.LinkedList; import java.util.List; import java.util.NoSuchElementException; +import java.util.Objects; import de.ovgu.featureide.fm.core.base.FeatureUtils; import de.ovgu.featureide.fm.core.base.IConstraint; @@ -486,4 +487,26 @@ public String toString() { return sb.toString(); } + @Override + public int hashCode() { + return Objects.hash(and, concrete, correspondingFeature, hidden, mandatory, multiple, parent, partOfConstraints); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final FeatureStructure other = (FeatureStructure) obj; + return (and == other.and) && (concrete == other.concrete) && Objects.equals(correspondingFeature, other.correspondingFeature) + && (hidden == other.hidden) && (mandatory == other.mandatory) && (multiple == other.multiple) && Objects.equals(parent, other.parent) + && Objects.equals(partOfConstraints, other.partOfConstraints); + } + } diff --git a/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Literal.java b/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Literal.java index 667bc65e54..9cb9a8bd1d 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Literal.java +++ b/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Literal.java @@ -61,7 +61,7 @@ public Literal(Object var, boolean positive) { } protected Literal(Literal oldLiteral) { - var = oldLiteral.var; + var = (oldLiteral.var instanceof String) ? new String((String) oldLiteral.var) : oldLiteral.var; positive = oldLiteral.positive; } @@ -130,18 +130,21 @@ public Literal clone() { @Override public int hashCode() { - return Objects.hashCode(var) * (positive ? 31 : 37); + return Objects.hash(positive, var); } @Override - public boolean equals(Object node) { - if (this == node) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (!(node instanceof Literal)) { + if (!super.equals(obj)) { return false; } - final Literal other = (Literal) node; + if (getClass() != obj.getClass()) { + return false; + } + final Literal other = (Literal) obj; return (positive == other.positive) && Objects.equals(var, other.var); } diff --git a/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Node.java b/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Node.java index 7971e28680..fdb5de70f7 100644 --- a/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Node.java +++ b/plugins/de.ovgu.featureide.fm.core/src/org/prop4j/Node.java @@ -320,27 +320,32 @@ public void removeDuplicates() { @Override public int hashCode() { - int hashCode = children.length * 37; - for (int i = 0; i < children.length; i++) { - hashCode += children[i].hashCode(); - } - return hashCode; + return Arrays.hashCode(children); } @Override - public boolean equals(Object object) { - if (this == object) { + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Node otherNode = (Node) obj; + if ((children == null) && (otherNode.children == null)) { return true; } - if (!getClass().isInstance(object)) { + if ((children == null) || (otherNode.children == null)) { return false; } - final Node otherNode = (Node) object; if (children.length != otherNode.children.length) { return false; } - final List thisChildrenList = Arrays.asList(children); - final List otherChildrenList = Arrays.asList(otherNode.children); + final LinkedHashSet thisChildrenList = new LinkedHashSet<>(Arrays.asList(children)); + final LinkedHashSet otherChildrenList = new LinkedHashSet<>(Arrays.asList(otherNode.children)); return thisChildrenList.containsAll(otherChildrenList) && otherChildrenList.containsAll(thisChildrenList); } diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/Commons.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/Commons.java index 41c5e0bc5e..bb56b4324d 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/Commons.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/Commons.java @@ -165,6 +165,12 @@ public static ExtendedFeatureModel getNewFormatBikeModel() { return (ExtendedFeatureModel) model; } + public static ExtendedFeatureModel getPCConfiguratorModel() { + IFeatureModel model = Commons.loadTestExtendedFeatureModelFromFile("PCConfiguratorModel.xml"); + assertTrue(model instanceof ExtendedFeatureModel); + return (ExtendedFeatureModel) model; + } + public static boolean compareByAttributeValues(ExtendedFeatureModel model1, ExtendedFeatureModel model2) { return compareModelToValueMap(model2, extractValueMap(model1)); } @@ -174,7 +180,7 @@ public static Map> extractValueMap(ExtendedFeatureMo for (IFeature feat : model.getFeatures()) { ExtendedFeature ext = (ExtendedFeature) feat; Map featValueMap = new HashMap<>(); - for (IFeatureAttribute att : ext.getAttributes()) { + for (IFeatureAttribute att : ext.getAttributes()) { featValueMap.put(att.getName(), att.getValue()); } valueMap.put(ext.getName(), featValueMap); @@ -190,7 +196,7 @@ public static boolean compareModelToValueMap(ExtendedFeatureModel model, Map att : ext.getAttributes()) { if (valueMap.get(ext.getName()).containsKey(att.getName())) { if (att.getValue() == null) { if (valueMap.get(ext.getName()).get(att.getName()) == null) { diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedConfiguration.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedConfiguration.java index ad717f6e11..d6057e26fd 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedConfiguration.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedConfiguration.java @@ -87,8 +87,8 @@ public void testMaximumEstimationComputationDouble() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Price")) { attributePrice = att; } @@ -118,8 +118,8 @@ public void testMinimumEstimationComputationDouble() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Price")) { attributePrice = att; } @@ -152,8 +152,8 @@ public void testMaximumEstimationComputationLong() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Calories")) { attributePrice = att; } @@ -186,8 +186,8 @@ public void testMinimumEstimationComputationLong() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Calories")) { attributePrice = att; } diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModel.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModel.java index 792dbd44ed..19680c84a5 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModel.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModel.java @@ -20,8 +20,21 @@ */ package de.ovgu.featureide.fm.attributes.tests; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertTrue; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Map.Entry; + import org.junit.Before; import org.junit.Test; @@ -68,4 +81,107 @@ public void test_createDefaultValues() { assertTrue(bFeature instanceof ExtendedFeature); assertTrue(!bFeature.getStructure().isRoot()); } + + @Test + public void testClone() throws IllegalArgumentException, IllegalAccessException { + ExtendedFeatureModel fm1 = Commons.getPCConfiguratorModel(); + classesUseDifferentMemory(fm1, fm1.clone(true), 0, "fm", new HashSet<>()); + } + + private static final LinkedHashSet unequalFields = new LinkedHashSet<>(Arrays.asList( // + "de.ovgu.featureide.fm.attributes.base.impl.ExtendedFeature#eventManager", // + "de.ovgu.featureide.fm.core.base.impl.Constraint#eventManager", // + "de.ovgu.featureide.fm.attributes.base.impl.ExtendedFeatureModel#eventManager", // + "de.ovgu.featureide.fm.core.RenamingsManager#eventManager")); + private static final LinkedHashSet sameFields = new LinkedHashSet<>(Arrays.asList( // + "de.ovgu.featureide.fm.attributes.base.impl.ExtendedFeatureModel#factoryID", // + "de.ovgu.featureide.fm.attributes.base.impl.ExtendedFeatureModel#factory", // + "org.prop4j.Literal#var", // + "id")); + private static final LinkedHashSet> wrapperClasses = + new LinkedHashSet<>(Arrays.asList(Double.class, Float.class, Long.class, Integer.class, Short.class, Character.class, Byte.class, Boolean.class)); + + private void classesUseDifferentMemory(Object o1, Object o2, int depth, String fieldName, HashSet alreadyChecked) + throws IllegalArgumentException, IllegalAccessException { + if (o1 == null && o2 == null) { + return; + } + + if (!alreadyChecked.add(System.identityHashCode(o1))) { + return; + } + + Class class1 = o1.getClass(); + Class class2 = o2.getClass(); + assertEquals(class1, class2); + + if (!unequalFields.contains(fieldName)) { + assertEquals(o1, o2); + } + + if (class1.isPrimitive() || wrapperClasses.contains(class1)) { + return; + } + + if (!sameFields.contains(fieldName)) { + assertNotSame(o1, o2); + } + + ArrayList allFields = new ArrayList<>(); + Class fieldClass = class1; + while (fieldClass != null) { + Field[] fields = fieldClass.getDeclaredFields(); + allFields.addAll(Arrays.asList(fields)); + fieldClass = fieldClass.getSuperclass(); + } + + for (Field field : allFields) { + if ((field.getModifiers() & (Modifier.STATIC | Modifier.TRANSIENT)) != 0) { + continue; + } + try { + field.setAccessible(true); + } catch (Exception e) { + continue; + } + Object i1 = field.get(o1); + Object i2 = field.get(o2); + if (i1 == null && i2 == null) { + continue; + } + + String childName = String.format("%s#%s", class1.getName(), field.getName()); + + if (Iterable.class.isAssignableFrom(field.getType())) { + Iterator iterator1 = ((Iterable) i1).iterator(); + Iterator iterator2 = ((Iterable) i2).iterator(); + int i = 0; + while (iterator1.hasNext()) { + classesUseDifferentMemory(iterator1.next(), iterator2.next(), depth + 1, childName + i, alreadyChecked); + } + assertFalse(iterator2.hasNext()); + } else if (Map.class.isAssignableFrom(field.getType())) { + Iterator> iterator1 = ((Map) i1).entrySet().iterator(); + Iterator> iterator2 = ((Map) i2).entrySet().iterator(); + int i = 0; + while (iterator1.hasNext()) { + Entry next1 = iterator1.next(); + Entry next2 = iterator2.next(); + classesUseDifferentMemory(next1.getKey(), next2.getKey(), depth + 1, childName + i + "key", alreadyChecked); + classesUseDifferentMemory(next1.getValue(), next2.getValue(), depth + 1, childName + i + "value", alreadyChecked); + } + assertFalse(iterator2.hasNext()); + } else if (field.getType().isArray()) { + Object[] array1 = (Object[]) i1; + Object[] array2 = (Object[]) i2; + assertEquals(array1.length, array2.length); + for (int i = 0; i < array1.length; i++) { + classesUseDifferentMemory(array1[i], array2[i], depth + 1, childName + i, alreadyChecked); + } + } else { + classesUseDifferentMemory(i1, i2, depth + 1, childName, alreadyChecked); + } + } + } + } diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModelSaveAndLoading.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModelSaveAndLoading.java index efe097aa9c..a98fae1bb9 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModelSaveAndLoading.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureModelSaveAndLoading.java @@ -118,16 +118,16 @@ public void test_CreationAndSaving() { assertTrue(eBaseFeature.getAttributes().size() == 0); // Create all types of attributes with values - IFeatureAttribute stringAttribute = attributeFactory.createStringAttribute(eRootFeature, "stringTest", "EMPTY", "Ein Test", false, false); - IFeatureAttribute booleanAttribute = attributeFactory.createBooleanAttribute(eRootFeature, "booleanTest", "State", true, false, false); - IFeatureAttribute longAttribute = attributeFactory.createLongAttribute(eRootFeature, "longTest", "Euro", Long.MAX_VALUE, false, false); - IFeatureAttribute doubleAttribute = attributeFactory.createDoubleAttribute(eRootFeature, "doubleTest", "Dollar", Double.MAX_VALUE, false, false); + IFeatureAttribute stringAttribute = attributeFactory.createStringAttribute(eRootFeature, "stringTest", "EMPTY", "Ein Test", false, false); + IFeatureAttribute booleanAttribute = attributeFactory.createBooleanAttribute(eRootFeature, "booleanTest", "State", true, false, false); + IFeatureAttribute longAttribute = attributeFactory.createLongAttribute(eRootFeature, "longTest", "Euro", Long.MAX_VALUE, false, false); + IFeatureAttribute doubleAttribute = attributeFactory.createDoubleAttribute(eRootFeature, "doubleTest", "Dollar", Double.MAX_VALUE, false, false); // Create all types of attributes with null values - IFeatureAttribute stringAttributeNull = attributeFactory.createStringAttribute(eRootFeature, "sNull", "", null, false, false); - IFeatureAttribute booleanAttributeNull = attributeFactory.createBooleanAttribute(eRootFeature, "bNull", "", null, false, false); - IFeatureAttribute longAttributeNull = attributeFactory.createLongAttribute(eRootFeature, "lNull", "", null, false, false); - IFeatureAttribute doubleAttributeNull = attributeFactory.createDoubleAttribute(eRootFeature, "dNull", "", null, false, false); + IFeatureAttribute stringAttributeNull = attributeFactory.createStringAttribute(eRootFeature, "sNull", "", null, false, false); + IFeatureAttribute booleanAttributeNull = attributeFactory.createBooleanAttribute(eRootFeature, "bNull", "", null, false, false); + IFeatureAttribute longAttributeNull = attributeFactory.createLongAttribute(eRootFeature, "lNull", "", null, false, false); + IFeatureAttribute doubleAttributeNull = attributeFactory.createDoubleAttribute(eRootFeature, "dNull", "", null, false, false); // Add the attributes to the feature eRootFeature.addAttribute(stringAttribute); @@ -187,10 +187,10 @@ public void test_CreationAndSaving() { assertTrue(!doubleAttribute.isConfigurable()); // Check Attributes with null values - IFeatureAttribute sN = eReadRootFeature.getAttributes().get(4); - IFeatureAttribute bN = eReadRootFeature.getAttributes().get(5); - IFeatureAttribute lN = eReadRootFeature.getAttributes().get(6); - IFeatureAttribute dN = eReadRootFeature.getAttributes().get(7); + IFeatureAttribute sN = eReadRootFeature.getAttributes().get(4); + IFeatureAttribute bN = eReadRootFeature.getAttributes().get(5); + IFeatureAttribute lN = eReadRootFeature.getAttributes().get(6); + IFeatureAttribute dN = eReadRootFeature.getAttributes().get(7); assertTrue(sN.getName().equals("sNull")); assertTrue(sN.getValue() == null); diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureTests.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureTests.java index e9d069cde5..4603e02901 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureTests.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedFeatureTests.java @@ -85,7 +85,7 @@ public void test_addAttributes() { // Get a feature ExtendedFeature breadFeature = (ExtendedFeature) model.getFeature("Bread"); // Create an attribute - IFeatureAttribute attribute = attributeFactory.createStringAttribute(breadFeature, "test", "Test", "Test Value", false, false); + IFeatureAttribute attribute = attributeFactory.createStringAttribute(breadFeature, "test", "Test", "Test Value", false, false); // Add the attribute to the feature assertTrue(breadFeature.getAttributes().size() == 3); breadFeature.addAttribute(attribute); @@ -103,7 +103,7 @@ public void test_removeAttributes() { // Get a feature ExtendedFeature breadFeature = (ExtendedFeature) model.getFeature("Bread"); // Create an attribute - IFeatureAttribute attribute = attributeFactory.createStringAttribute(breadFeature, "test", "Test", "Test Value", false, false); + IFeatureAttribute attribute = attributeFactory.createStringAttribute(breadFeature, "test", "Test", "Test Value", false, false); // Add the attribute to the feature assertTrue(breadFeature.getAttributes().size() == 3); breadFeature.addAttribute(attribute); @@ -124,7 +124,7 @@ public void test_clone() { ExtendedFeature testFeature = factory.createFeature(model, "Test"); // Create an attribute - IFeatureAttribute attribute = attributeFactory.createStringAttribute(testFeature, "test", "Test", "Test Value", true, true); + IFeatureAttribute attribute = attributeFactory.createStringAttribute(testFeature, "test", "Test", "Test Value", true, true); // Add the attribute to the feature testFeature.addAttribute(attribute); @@ -133,7 +133,7 @@ public void test_clone() { assertTrue(cloneF instanceof ExtendedFeature); ExtendedFeature cloneExF = (ExtendedFeature) cloneF; assertTrue(cloneExF.getAttributes().size() == 1); - IFeatureAttribute attributeClone = cloneExF.getAttributes().get(0); + IFeatureAttribute attributeClone = cloneExF.getAttributes().get(0); assertTrue(attributeClone.getFeature() == cloneExF); assertTrue(attributeClone.getName().equals("test")); assertTrue(attributeClone instanceof StringFeatureAttribute); @@ -154,7 +154,7 @@ public void test_isContainingAttribute() { // Get a feature ExtendedFeature breadFeature = (ExtendedFeature) model.getFeature("Bread"); - for (IFeatureAttribute att : breadFeature.getAttributes()) { + for (IFeatureAttribute att : breadFeature.getAttributes()) { assertTrue(breadFeature.isContainingAttribute(att)); } } diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedOutline.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedOutline.java index df732c45e7..c7080d3b3a 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedOutline.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TExtendedOutline.java @@ -60,8 +60,8 @@ public void testMaximumEstimationComputationDouble() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Price")) { attributePrice = att; } @@ -91,8 +91,8 @@ public void testMinimumEstimationComputationDouble() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Price")) { attributePrice = att; } @@ -122,8 +122,8 @@ public void testCountAttributeComputation() { // Get attribute to compute ExtendedFeature feature = (ExtendedFeature) model.getStructure().getRoot().getFeature(); - IFeatureAttribute attributePrice = null; - for (IFeatureAttribute att : feature.getAttributes()) { + IFeatureAttribute attributePrice = null; + for (IFeatureAttribute att : feature.getAttributes()) { if (att.getName().equals("Price")) { attributePrice = att; } diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TFeatureAttributeFactory.java b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TFeatureAttributeFactory.java index 342fc72813..915f2212ea 100644 --- a/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TFeatureAttributeFactory.java +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/de/ovgu/featureide/fm/attributes/tests/TFeatureAttributeFactory.java @@ -26,10 +26,13 @@ import de.ovgu.featureide.fm.attributes.FMAttributesLibrary; import de.ovgu.featureide.fm.attributes.base.AbstractFeatureAttributeFactory; -import de.ovgu.featureide.fm.attributes.base.IFeatureAttribute; +import de.ovgu.featureide.fm.attributes.base.impl.BooleanFeatureAttribute; +import de.ovgu.featureide.fm.attributes.base.impl.DoubleFeatureAttribute; import de.ovgu.featureide.fm.attributes.base.impl.ExtendedFeature; import de.ovgu.featureide.fm.attributes.base.impl.ExtendedFeatureModel; import de.ovgu.featureide.fm.attributes.base.impl.FeatureAttributeFactory; +import de.ovgu.featureide.fm.attributes.base.impl.LongFeatureAttribute; +import de.ovgu.featureide.fm.attributes.base.impl.StringFeatureAttribute; import de.ovgu.featureide.fm.core.init.FMCoreLibrary; import de.ovgu.featureide.fm.core.init.LibraryManager; @@ -50,16 +53,16 @@ public void test_AttributeInit() { ExtendedFeature root = (ExtendedFeature) model.getFeature("Root"); // Create all types of attributes with values - IFeatureAttribute stringAttribute = attributeFactory.createStringAttribute(root, "stringTest", "EMPTY", "Ein Test", false, false); - IFeatureAttribute booleanAttribute = attributeFactory.createBooleanAttribute(root, "booleanTest", "State", true, true, false); - IFeatureAttribute longAttribute = attributeFactory.createLongAttribute(root, "longTest", "Euro", Long.MAX_VALUE, false, true); - IFeatureAttribute doubleAttribute = attributeFactory.createDoubleAttribute(root, "doubleTest", "Dollar", Double.MAX_VALUE, true, true); + StringFeatureAttribute stringAttribute = attributeFactory.createStringAttribute(root, "stringTest", "EMPTY", "Ein Test", false, false); + BooleanFeatureAttribute booleanAttribute = attributeFactory.createBooleanAttribute(root, "booleanTest", "State", true, true, false); + LongFeatureAttribute longAttribute = attributeFactory.createLongAttribute(root, "longTest", "Euro", Long.MAX_VALUE, false, true); + DoubleFeatureAttribute doubleAttribute = attributeFactory.createDoubleAttribute(root, "doubleTest", "Dollar", Double.MAX_VALUE, true, true); // Create all types of attributes with null values - IFeatureAttribute stringAttributeNull = attributeFactory.createStringAttribute(root, "sNull", "", null, true, true); - IFeatureAttribute booleanAttributeNull = attributeFactory.createBooleanAttribute(root, "bNull", "", null, false, true); - IFeatureAttribute longAttributeNull = attributeFactory.createLongAttribute(root, "lNull", "", null, true, false); - IFeatureAttribute doubleAttributeNull = attributeFactory.createDoubleAttribute(root, "dNull", "", null, false, false); + StringFeatureAttribute stringAttributeNull = attributeFactory.createStringAttribute(root, "sNull", "", null, true, true); + BooleanFeatureAttribute booleanAttributeNull = attributeFactory.createBooleanAttribute(root, "bNull", "", null, false, true); + LongFeatureAttribute longAttributeNull = attributeFactory.createLongAttribute(root, "lNull", "", null, true, false); + DoubleFeatureAttribute doubleAttributeNull = attributeFactory.createDoubleAttribute(root, "dNull", "", null, false, false); assertTrue(stringAttribute.getName().equals("stringTest")); assertTrue(stringAttribute.getUnit().equals("EMPTY")); diff --git a/tests/de.ovgu.featureide.fm.attributes-test/src/extendedTestFeatureModels/PCConfiguratorModel.xml b/tests/de.ovgu.featureide.fm.attributes-test/src/extendedTestFeatureModels/PCConfiguratorModel.xml new file mode 100644 index 0000000000..82eaf9963f --- /dev/null +++ b/tests/de.ovgu.featureide.fm.attributes-test/src/extendedTestFeatureModels/PCConfiguratorModel.xml @@ -0,0 +1,1580 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1070 Series + +1070-Ti Series + +1080 Series + +1080-Ti Series + +P5000 Pny + +P6000 Pny +RX580 + + + + + + + +VS550 + +VS650 + +Corsair TX-M-Series + +Corsair HX-Series + +500 W + +500 W CM + +600 W + +600 W CM + +700 W + +700 W CM + +Bequiet Dark Power +Argus + + + + + + + + + + + + + + + + +Stufe 1 + +Stufe 2 +Stufe 3 + + + +Be Quiet Dark Roch Pro 3 + +Scythe Asura + +MSI Core Frozr XL + +Argus Storm 2 + +Corsair H100i + +Corsair H115i + +Bequiet Water Cooling +NZXT Water Cooling + + + + + + + + + + + + +Corsair Vengeance RGB Black + +4x 8GB DDR4-2133 + +4x 16GB DDR4-2133 + +4x 8GB DDR4-2400 +4x 16GB DDR4-2400 + + + + + +MSI Z270 PC MATE + +MSI Z270 Gaming Pro Carbon + +Z270F GAMING +IX HERO Gaming + + + + + + + + +Corsair H115i + +Silent Loop 280mm +Silent Loop 360mm + + + +Corsair Obsidian 450D + +Phanteks Enthoo Pro + +Silent Base 800 + +Thermaltake Suppressor F51 + +Thermaltake Core X31 + +Corsair Carbide Air 540 Cube + +Dark Base Pro 900 + +Corsair Obsidian 750D + +NZXT H630 + +Cougar Panzer Max + +Cooler Master Storm Trooper +Corsair Obsidian 750D + + + + + + + + + + + + + + + + +MSI Z270 PC MATE + +MSI Z270 Gaming Pro Carbon + +H270-PLUS + +Z270-K + +Z270F GAMING +IX HERO Gaming + + + + + + +Aerocool Aero-800 + +Aerocool Battlehawk V2 + +Corsair Obsidian 450D + +Phanteks Enthoo Pro + +Silent Base 800 + +Thermaltake Core V51 + +Thermaltake Suppressor F51 + +Thermaltake Core X31 + +Corsair Carbide Air 540 Cube + +Dark Base Pro 900 + +Corsair Obsidian 750D + +NZXT H630 + +Cougar Panzer Max +Cooler Master Storm Trooper + + + + + + + + + + + + + + + + + + +MSI Core Frozr + +Big Tower Cooler + +Argus Water Cooling + +Corsair Water Cooling + +Bequiet Water Cooling +NZXT Water Cooling + + + + + + +Aerocool Aero-800 + +Aerocool Battlehawk V2 + +Corsair Obsidian 450D + +Phanteks Enthoo Pro + +Silent Base 800 + +Thermaltake Core V51 + +Thermaltake Suppressor F51 + +Thermaltake Core X31 + +Corsair Carbide Air 540 Cube + +Dark Base Pro 900 + +Corsair Obsidian 750D + +NZXT H630 + +Cougar Panzer Max +Cooler Master Storm Trooper + + + + + + + + + + + + + + + + + + +XG-C100C + +LAN + +ASUS Soundcard +2x USB3.1 + + + + + +MSI B250M PRO-VDH + + + +MSI B250M GAMING PRO + + +B250M-A + + + + + + + +i7 Overclocked + +MSI B250M PRO-VDH + +MSI B250M GAMING PRO + +B250M-A + +B250M-PLUS + +H270-PLUS +IX HERO Gaming + + + + + + + + + + +Corsair Carbide 270R + +BitFenix Aegis + +M-908 + +M-909 + +Corsair Carbide Clear 400c + +NZXT H440 white + +NZXT H440 black + +Thermaltake Versa N27 + +Thermaltake View 31 + +anidees AI-Crystal + +Thermaltake Core V21 +Design Tower + + + + + + + + + + + + + +DVD-Drive + + + +BluRay-Drive + + +Hard Drive Caddies + + + + + + + +4x USB3.0 + + +B250M-A + + +Netis WF2113 + + + + + + +2x USB3.1 + + +B250M-A + + + +MSI B250M GAMING PRO + + + +MSI B250M PRO-VDH + + +LAN + + + + + + + + + +Stufe 2 +Stufe 3 + + + +Scythe Asura + + + +Silent Loop 120mm + + +NZXT Water Cooling + + + + + + + + + +