Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331209 - feature with unique=false implemented by unique list
Summary: feature with unique=false implemented by unique list
Status: CLOSED DUPLICATE of bug 89325
Alias: None
Product: EMF
Classification: Modeling
Component: Core (show other bugs)
Version: 2.7.0   Edit
Hardware: PC Windows 7
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-26 09:48 EST by Nicolas Bros CLA
Modified: 2010-11-26 10:10 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Bros CLA 2010-11-26 09:48:34 EST
I have a metamodel with a feature on which "unique" is false :

<eStructuralFeatures xsi:type="ecore:EReference" name="naryReference_notUnique" unique="false" upperBound="-1" eType="#//Class2"/>

EMF Generates this implementation for this feature's getter:

public EList<Class2> getNaryReference_notUnique() {
  if (naryReference_notUnique == null) {
    naryReference_notUnique = new EObjectResolvingEList<Class2>(Class2.class, this, SamplemmPackage.CLASS1__NARY_REFERENCE_NOT_UNIQUE);
  }
  return naryReference_notUnique;
}

On EObjectResolvingEList, the method isUnique() (inherited from EObjectEList) returns true.
Comment 1 Ed Merks CLA 2010-11-26 09:54:03 EST

*** This bug has been marked as a duplicate of bug 89325 ***
Comment 2 Nicolas Bros CLA 2010-11-26 10:10:51 EST
For future reference, a workaround is to override isUnique on the returned list (and mark the method @generated NOT):

/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public EList<Class2> getNaryReference_notUnique() {
  if (this.naryReference_notUnique == null) {
    this.naryReference_notUnique = new EObjectResolvingEList<Class2>(Class2.class, this, SamplemmPackage.CLASS1__NARY_REFERENCE_NOT_UNIQUE) {
      @Override
      protected boolean isUnique() {
        return false;
      }
    };
  }
  return this.naryReference_notUnique;
}