[129964] Updating templates based on new subset/superset enforcement logic.
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenClass.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenClass.java
index efa2846..7c96634 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenClass.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenClass.java
@@ -8,7 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *
- * $Id: GenClass.java,v 1.10 2006/02/22 20:48:43 khussey Exp $
+ * $Id: GenClass.java,v 1.11 2006/03/01 17:57:18 khussey Exp $
  */
 package org.eclipse.uml2.codegen.ecore.genmodel;
 
@@ -74,6 +74,9 @@
 
 	List/* GenFeature */getSupersetGenFeatures(GenFeature subsetGenFeature);
 
+	List/* GenFeature */getSupersetGenFeatures(GenFeature subsetGenFeature,
+			boolean includeDerived, boolean includeListType);
+
 	String getSupersetFeatureAccessorArray(GenFeature subsetGenFeature);
 
 	boolean isSuperset(GenFeature genFeature);
@@ -86,6 +89,9 @@
 
 	List/* GenFeature */getSubsetGenFeatures(GenFeature supersetGenFeature);
 
+	List/* GenFeature */getSubsetGenFeatures(GenFeature supersetGenFeature,
+			boolean includeDerived, boolean includeListType);
+
 	List/* GenFeature */getIsSetSubsetGenFeatures(GenFeature unionGenFeature);
 
 	String getSubsetFeatureAccessorArray(GenFeature supersetGenFeature);
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenClassImpl.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenClassImpl.java
index f19324a..d24814f 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenClassImpl.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenClassImpl.java
@@ -8,7 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *
- * $Id: GenClassImpl.java,v 1.25 2006/02/22 20:48:43 khussey Exp $
+ * $Id: GenClassImpl.java,v 1.26 2006/03/01 17:57:18 khussey Exp $
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.impl;
 
@@ -877,7 +877,12 @@
 	}
 
 	public List getSubsetGenFeatures(GenFeature supersetGenFeature,
-			boolean includedDerived) {
+			boolean includeDerived) {
+		return getSubsetGenFeatures(supersetGenFeature, includeDerived, true);
+	}
+
+	public List getSubsetGenFeatures(GenFeature supersetGenFeature,
+			boolean includeDerived, boolean includeListType) {
 		Map subsetGenFeatures = new LinkedHashMap();
 
 		final EStructuralFeature supersetEcoreFeature = supersetGenFeature
@@ -888,7 +893,8 @@
 
 			if (Generator.getSubsettedEcoreFeatures(
 				genFeature.getEcoreFeature()).contains(supersetEcoreFeature)
-				&& (includedDerived || !genFeature.isDerived())) {
+				&& (includeDerived || !genFeature.isDerived())
+				&& (includeListType || !genFeature.isListType())) {
 
 				subsetGenFeatures.put(genFeature.getName(), genFeature);
 			}
@@ -1019,16 +1025,19 @@
 
 	public List getSupersetGenFeatures(GenFeature subsetGenFeature,
 			boolean includeDerived) {
-		return includeDerived
-			? UML2GenModelUtil.getSubsettedGenFeatures(subsetGenFeature)
-			: collectGenFeatures(null, UML2GenModelUtil
-				.getSubsettedGenFeatures(subsetGenFeature),
-				new GenFeatureFilter() {
+		return getSupersetGenFeatures(subsetGenFeature, includeDerived, true);
+	}
 
-					public boolean accept(GenFeature genFeature) {
-						return !genFeature.isDerived();
-					}
-				});
+	public List getSupersetGenFeatures(GenFeature subsetGenFeature,
+			final boolean includeDerived, final boolean includeListType) {
+		return collectGenFeatures(null, UML2GenModelUtil
+			.getSubsettedGenFeatures(subsetGenFeature), new GenFeatureFilter() {
+
+			public boolean accept(GenFeature genFeature) {
+				return (includeDerived || !genFeature.isDerived())
+					&& (includeListType || !genFeature.isListType());
+			}
+		});
 	}
 
 	public List getImplementedSupersetGenFeatures() {
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java
index c82db9c..2df5fad 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/util/UML2GenModelUtil.java
@@ -8,7 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *
- * $Id: UML2GenModelUtil.java,v 1.12 2006/02/22 20:48:43 khussey Exp $
+ * $Id: UML2GenModelUtil.java,v 1.13 2006/03/01 17:57:18 khussey Exp $
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.util;
 
@@ -304,6 +304,16 @@
 			: Collections.EMPTY_LIST;
 	}
 
+	public static List getSupersetGenFeatures(GenClass genClass,
+			GenFeature subsetGenFeature, boolean includeDerived,
+			boolean includeListType) {
+		return genClass instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenClass
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenClass) genClass)
+				.getSupersetGenFeatures(subsetGenFeature, includeDerived,
+					includeListType)
+			: Collections.EMPTY_LIST;
+	}
+
 	public static String getSupersetFeatureAccessorArray(GenClass genClass,
 			GenFeature subsetGenFeature) {
 		return genClass instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenClass
@@ -348,6 +358,16 @@
 			: Collections.EMPTY_LIST;
 	}
 
+	public static List getSubsetGenFeatures(GenClass genClass,
+			GenFeature supersetGenFeature, boolean includeDerived,
+			boolean includeListType) {
+		return genClass instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenClass
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenClass) genClass)
+				.getSubsetGenFeatures(supersetGenFeature, includeDerived,
+					includeListType)
+			: Collections.EMPTY_LIST;
+	}
+
 	public static List getIsSetSubsetGenFeatures(GenClass genClass,
 			GenFeature unionGenFeature) {
 		return genClass instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenClass
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.post.insert.javajetinc b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.post.insert.javajetinc
index ed9515a..7773fd3 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.post.insert.javajetinc
+++ b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.post.insert.javajetinc
@@ -1,16 +1,38 @@
-<%for (Iterator subsetGenFeatures = UML2GenModelUtil.getSubsetGenFeatures(genClass, genFeature).iterator(); subsetGenFeatures.hasNext(); ) { GenFeature subsetGenFeature = (GenFeature) subsetGenFeatures.next();%>
-  <%if (!subsetGenFeature.isListType() && !UML2GenModelUtil.isUnion(subsetGenFeature)) {%>
-		if (<%=subsetGenFeature.isContainer() ? subsetGenFeature.getGetAccessor() + "()" : (genModel.isVirtualDelegation() ? "eVirtualGet(" + genClass.getQualifiedFeatureID(subsetGenFeature) + ")" : subsetGenFeature.getSafeName())%> != null && <%=subsetGenFeature.isContainer() ? subsetGenFeature.getGetAccessor() + "()" : (genModel.isVirtualDelegation() ? "eVirtualGet(" + genClass.getQualifiedFeatureID(subsetGenFeature) + ")" : subsetGenFeature.getSafeName())%> != new<%=genFeature.getCapName()%>)
-		{
-			set<%=subsetGenFeature.getAccessorName()%>(null);
-		}
+<%if (!UML2GenModelUtil.getSubsetGenFeatures(genClass, genFeature, false, false).isEmpty() || !UML2GenModelUtil.getSupersetGenFeatures(genClass, genFeature, false, true).isEmpty()) {%>
+		<%=genModel.getImportedName("org.eclipse.emf.ecore.resource.Resource")%>.Internal eInternalResource = eInternalResource();
+		if (eInternalResource == null || !eInternalResource.isLoading()) {
+  <%for (Iterator subsetGenFeatures = UML2GenModelUtil.getSubsetGenFeatures(genClass, genFeature, false, false).iterator(); subsetGenFeatures.hasNext(); ) { GenFeature subsetGenFeature = (GenFeature) subsetGenFeatures.next();%>
+    <%if (subsetGenFeature.isContainer()) {%>
+			<%=subsetGenFeature.getImportedType()%> <%=subsetGenFeature.getSafeName()%> = <%=subsetGenFeature.isBasicGet() ? "basicGet" + subsetGenFeature.getAccessorName() : subsetGenFeature.getGetAccessor()%>();
+    <%} else if (genClass.getImplementingGenModel(subsetGenFeature).isVirtualDelegation()) {%>
+			Object <%=subsetGenFeature.getSafeName()%> = eVirtualGet(<%=genClass.getQualifiedFeatureID(subsetGenFeature)%>);
+    <%}%>
+			if (<%=subsetGenFeature.getSafeName()%> != null && <%=subsetGenFeature.getSafeName()%> != new<%=genFeature.getCapName()%>)
+			{
+				set<%=subsetGenFeature.getAccessorName()%>(null);
+			}
   <%}%>
-<%}%>
-<%for (Iterator supersetGenFeatures = UML2GenModelUtil.getSupersetGenFeatures(genClass, genFeature).iterator(); supersetGenFeatures.hasNext(); ) { GenFeature supersetGenFeature = (GenFeature) supersetGenFeatures.next();%>
-  <%if (!supersetGenFeature.isListType() && !UML2GenModelUtil.isUnion(supersetGenFeature)) {%>
-		if (new<%=genFeature.getCapName()%> != null ||  old<%=genFeature.getCapName()%> == <%=supersetGenFeature.isContainer() ? supersetGenFeature.getGetAccessor() + "()" : (genModel.isVirtualDelegation() ? "eVirtualGet(" + genClass.getQualifiedFeatureID(supersetGenFeature) + ")" : supersetGenFeature.getSafeName())%>)
-		{
-			set<%=supersetGenFeature.getAccessorName()%>(new<%=genFeature.getCapName()%>);
-		}
+  <%for (Iterator supersetGenFeatures = UML2GenModelUtil.getSupersetGenFeatures(genClass, genFeature, false, true).iterator(); supersetGenFeatures.hasNext(); ) { GenFeature supersetGenFeature = (GenFeature) supersetGenFeatures.next();%>
+			if (new<%=genFeature.getCapName()%> != null)
+			{
+    <%if (supersetGenFeature.isListType()) {%>
+				<%=supersetGenFeature.getImportedType()%> <%=supersetGenFeature.getSafeName()%> = <%=supersetGenFeature.getGetAccessor()%>();
+				if (!<%=supersetGenFeature.getSafeName()%>.contains(new<%=genFeature.getCapName()%>))
+				{
+					<%=supersetGenFeature.getSafeName()%>.add(new<%=genFeature.getCapName()%>);
+				}
+    <%} else {%>
+      <%if (supersetGenFeature.isContainer()) {%>
+				<%=supersetGenFeature.getImportedType()%> <%=supersetGenFeature.getSafeName()%> = <%=supersetGenFeature.isBasicGet() ? "basicGet" + supersetGenFeature.getAccessorName() : supersetGenFeature.getGetAccessor()%>();
+      <%} else if (genClass.getImplementingGenModel(supersetGenFeature).isVirtualDelegation()) {%>
+				Object <%=supersetGenFeature.getSafeName()%> = eVirtualGet(<%=genClass.getQualifiedFeatureID(supersetGenFeature)%>);
+      <%}%>
+				if (new<%=genFeature.getCapName()%> != <%=supersetGenFeature.getSafeName()%>)
+				{
+					set<%=supersetGenFeature.getAccessorName()%>(new<%=genFeature.getCapName()%>);
+				}
+    <%}%>
+			}
   <%}%>
+		}
 <%}%>
\ No newline at end of file
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.pre.insert.javajetinc b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.pre.insert.javajetinc
deleted file mode 100644
index cc4156b..0000000
--- a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/basicSetGenFeature.pre.insert.javajetinc
+++ /dev/null
@@ -1,8 +0,0 @@
-<%for (Iterator supersetGenFeatures = UML2GenModelUtil.getSupersetGenFeatures(genClass, genFeature).iterator(); supersetGenFeatures.hasNext(); ) { GenFeature supersetGenFeature = (GenFeature) supersetGenFeatures.next();%>
-  <%if (supersetGenFeature.isListType() && !UML2GenModelUtil.isUnion(supersetGenFeature)) {%>
-		if (new<%=genFeature.getCapName()%> != null && !<%=supersetGenFeature.getGetAccessor()%>().contains(new<%=genFeature.getCapName()%>))
-		{
-			<%=supersetGenFeature.getGetAccessor()%>().add(new<%=genFeature.getCapName()%>);
-		}
-  <%}%>
-<%}%>
\ No newline at end of file
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.post.insert.javajetinc b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.post.insert.javajetinc
index b11db37..6b177a6 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.post.insert.javajetinc
+++ b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.post.insert.javajetinc
@@ -1,18 +1,3 @@
 <%if (!genFeature.isBasicSet()) {%>
-  <%for (Iterator subsetGenFeatures = UML2GenModelUtil.getSubsetGenFeatures(genClass, genFeature).iterator(); subsetGenFeatures.hasNext(); ) { GenFeature subsetGenFeature = (GenFeature) subsetGenFeatures.next();%>
-    <%if (!subsetGenFeature.isListType() && !UML2GenModelUtil.isUnion(subsetGenFeature)) {%>
-		if (<%=subsetGenFeature.isContainer() ? subsetGenFeature.getGetAccessor() + "()" : (genModel.isVirtualDelegation() ? "eVirtualGet(" + genClass.getQualifiedFeatureID(subsetGenFeature) + ")" : subsetGenFeature.getSafeName())%> != null && <%=subsetGenFeature.isContainer() ? subsetGenFeature.getGetAccessor() + "()" : (genModel.isVirtualDelegation() ? "eVirtualGet(" + genClass.getQualifiedFeatureID(subsetGenFeature) + ")" : subsetGenFeature.getSafeName())%> != new<%=genFeature.getCapName()%>)
-		{
-			set<%=subsetGenFeature.getAccessorName()%>(null);
-		}
-    <%}%>
-  <%}%>
-  <%for (Iterator supersetGenFeatures = UML2GenModelUtil.getSupersetGenFeatures(genClass, genFeature).iterator(); supersetGenFeatures.hasNext(); ) { GenFeature supersetGenFeature = (GenFeature) supersetGenFeatures.next();%>
-    <%if (!supersetGenFeature.isListType() && !UML2GenModelUtil.isUnion(supersetGenFeature)) {%>
-		if (new<%=genFeature.getCapName()%> != null || old<%=genFeature.getCapName()%> == <%=supersetGenFeature.isContainer() ? supersetGenFeature.getGetAccessor() + "()" : (genModel.isVirtualDelegation() ? "eVirtualGet(" + genClass.getQualifiedFeatureID(supersetGenFeature) + ")" : supersetGenFeature.getSafeName())%>)
-		{
-			set<%=supersetGenFeature.getAccessorName()%>(new<%=genFeature.getCapName()%>);
-		}
-    <%}%>
-  <%}%>
+<%@ include file="basicSetGenFeature.post.insert.javajetinc" fail="silent" %>
 <%}%>
\ No newline at end of file
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.pre.insert.javajetinc b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.pre.insert.javajetinc
index b0b5fbc..0bdf1e6 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.pre.insert.javajetinc
+++ b/plugins/org.eclipse.uml2.codegen.ecore/templates/model/Class/setGenFeature.pre.insert.javajetinc
@@ -1,19 +1,3 @@
-<%if ("java.lang.String".equals(genFeature.getType()) && UML2GenModelUtil.isSafeStrings(genModel)) {%>
+<%if (genFeature.isStringType() && UML2GenModelUtil.isSafeStrings(genModel)) {%>
 		new<%=genFeature.getCapName()%> = new<%=genFeature.getCapName()%> == null ? <%=genFeature.getUpperName()%>_EDEFAULT : new<%=genFeature.getCapName()%>;
-<%}%>
-<%if (!genFeature.isBasicSet()) { boolean first = genFeature.isContainer() && !genFeature.isVolatile();%>
-  <%for (Iterator supersetGenFeatures = UML2GenModelUtil.getSupersetGenFeatures(genClass, genFeature).iterator(); supersetGenFeatures.hasNext(); ) { GenFeature supersetGenFeature = (GenFeature) supersetGenFeatures.next();%>
-    <%if (!UML2GenModelUtil.isUnion(supersetGenFeature)) {%>
-      <%if (supersetGenFeature.isListType()) {%>
-		if (new<%=genFeature.getCapName()%> != null && !<%=supersetGenFeature.getGetAccessor()%>().contains(new<%=genFeature.getCapName()%>))
-		{
-			<%=supersetGenFeature.getGetAccessor()%>().add(new<%=genFeature.getCapName()%>);
-		}
-      <%} else {%>
-        <%if (first) { first = false;%>
-		<%=genModel.getImportedName("org.eclipse.emf.ecore.EObject")%> old<%=genFeature.getCapName()%> = eContainer();
-        <%}%>
-      <%}%>
-    <%}%>
-  <%}%>
 <%}%>
\ No newline at end of file