}
for (Iterator i = eReferenceToOppositeNameMap.entrySet().iterator(); i.hasNext(); )
{
Map.Entry entry = (Map.Entry)i.next();
EReference eReference = (EReference)entry.getKey();
String opposite = (String)entry.getValue();
EClass oppositeEClass = eReference.getEReferenceType();
if (eReference.getEOpposite() == null)
{
EStructuralFeature eOppositeFeature = oppositeEClass.getEStructuralFeature(opposite);
// Match by XML name if this fails.
if (eOppositeFeature == null)
{
for (Iterator j = oppositeEClass.getEAllStructuralFeatures().iterator(); j.hasNext(); )
{
EStructuralFeature feature = (EStructuralFeature)j.next();
if (opposite.equals(extendedMetaData.getName(feature)))
{
eOppositeFeature = feature;
break;
}
}
}
if (eOppositeFeature instanceof EReference)
{
EReference eOpposite = (EReference)eOppositeFeature;
eOpposite.setEOpposite(eReference);
eReference.setEOpposite(eOpposite);
}
}
if (eReference.getEOpposite() == null && eReference.isContainment())
{
EReference eOpposite = ecoreFactory.createEReference();
eOpposite.setName(opposite);
eOpposite.setEType(eReference.getEContainingClass());
eOpposite.setLowerBound(0);
eOpposite.setEOpposite(eReference);
eReference.setEOpposite(eOpposite);
eOpposite.setTransient(true);
oppositeEClass.getEStructuralFeatures().add(eOpposite);
}
}
eReferenceToOppositeNameMap.clear();