Issue 13456: CompoundValue::equals does not conform to Annex A conventions (fuml-ftf) Source: Model Driven Solutions (Mr. Ed Seidewitz, ed-s(at)modeldriven.com) Nature: Uncategorized Issue Severity: Summary: Specification: Semantics of a Foundation Subset for Executable UML Models, FTF – Beta 1 (ptc/08-11-03) Section: 8.3.2.2.2 CompoundValue Summary: The CompoundValue::equals operation has more than one return statement and uses the “&&”. These are not allowed by the conventions of Annex A. Proposed Resolution: Replace the body of the equals operation with: boolean isEqual = otherValue instanceof CompoundValue; if (isEqual) { CompoundValue otherCompoundValue = (CompoundValue)otherValue; // Debug.println("[equals] " + this.featureValues.size() + " feature(s)."); isEqual = super.equals(otherValue) & otherCompoundValue.featureValues.size() == this.featureValues.size(); int i = 1; while (isEqual & i <= this.featureValues.size()) { FeatureValue thisFeatureValue = this.featureValues.getValue(i-1); boolean matched = false; int j = 1; while (!matched & j <= otherCompoundValue.featureValues.size()) { FeatureValue otherFeatureValue = otherCompoundValue.featureValues.getValue(j-1); if (thisFeatureValue.feature == otherFeatureValue.feature) { matched = thisFeatureValue.hasEqualValues(otherFeatureValue); } j = j + 1; } isEqual = matched; i = i + 1; } } return isEqual; Resolution: Change the code as proposed Revised Text: Replace the body of the CompoundValue::equals operation with: boolean isEqual = otherValue instanceof CompoundValue; if (isEqual) { CompoundValue otherCompoundValue = (CompoundValue)otherValue; // Debug.println("[equals] " + this.featureValues.size() + " feature(s)."); isEqual = super.equals(otherValue) & otherCompoundValue.featureValues.size() == this.featureValues.size(); int i = 1; while (isEqual & i <= this.featureValues.size()) { FeatureValue thisFeatureValue = this.featureValues.getValue(i-1); boolean matched = false; int j = 1; while (!matched & j <= otherCompoundValue.featureValues.size()) { FeatureValue otherFeatureValue = otherCompoundValue.featureValues.getValue(j-1); if (thisFeatureValue.feature == otherFeatureValue.feature) { matched = thisFeatureValue.hasEqualValues(otherFeatureValue); } j = j + 1; } isEqual = matched; i = i + 1; } } Actions taken: February 6, 2009: received issue July 23, 2010: closed issue Discussion: End of Annotations:===== ubject: CompoundValue::equals does not conform to Annex A conventions Date: Fri, 6 Feb 2009 18:44:13 -0500 X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: CompoundValue::equals does not conform to Annex A conventions thread-index: AcmItNCApzXTGc/RTSCOC5Kpzhy4yw== From: "Ed Seidewitz" To: Specification: Semantics of a Foundation Subset for Executable UML Models, FTF . Beta 1 (ptc/08-11-03) Section: 8.3.2.2.2 CompoundValue Summary: The CompoundValue::equals operation has more than one return statement and uses the .&&.. These are not allowed by the conventions of Annex A. Proposed Resolution: Replace the body of the equals operation with: boolean isEqual = otherValue instanceof CompoundValue; if (isEqual) { CompoundValue otherCompoundValue = (CompoundValue)otherValue; // Debug.println("[equals] " + this.featureValues.size() + " feature(s)."); isEqual = super.equals(otherValue) & otherCompoundValue.featureValues.size() == this.featureValues.size(); int i = 1; while (isEqual & i <= this.featureValues.size()) { FeatureValue thisFeatureValue = this.featureValues.getValue(i-1); boolean matched = false; int j = 1; while (!matched & j <= otherCompoundValue.featureValues.size()) { FeatureValue otherFeatureValue = otherCompoundValue.featureValues.getValue(j-1); if (thisFeatureValue.feature == otherFeatureValue.feature) { matched = thisFeatureValue.hasEqualValues(otherFeatureValue); } j = j + 1; } isEqual = matched; i = i + 1; } } return isEqual;