[212765] Adding codegen APIs for accessing redefinition details.
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/Generator.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/Generator.java
index 3231221..226fa2c 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/Generator.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/Generator.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2006 IBM Corporation and others.
+ * Copyright (c) 2005, 2013 IBM Corporation, CEA, and others.
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -7,22 +7,27 @@
  *
  * Contributors:
  *   IBM - initial API and implementation
- *
- * $Id: Generator.java,v 1.5 2006/12/20 19:54:15 khussey Exp $
+ *   Kenn Hussey (CEA) - 212765
  */
 package org.eclipse.uml2.codegen.ecore;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 
+import org.eclipse.emf.common.util.ECollections;
+import org.eclipse.emf.common.util.EMap;
 import org.eclipse.emf.common.util.UniqueEList;
 import org.eclipse.emf.ecore.EAnnotation;
 import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
 import org.eclipse.emf.ecore.EObject;
 import org.eclipse.emf.ecore.EOperation;
 import org.eclipse.emf.ecore.EStructuralFeature;
 import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.resource.ResourceSet;
 import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.uml2.common.util.UML2Util;
 
 /**
  * 
@@ -106,6 +111,76 @@
 		return redefinedEcoreOperations;
 	}
 
+	protected static EMap<String, String> getRedefinitionDetails(
+			EStructuralFeature eStructuralFeature) {
+		EObject eContainer = eStructuralFeature.eContainer();
+
+		if (eContainer instanceof EAnnotation) {
+			EAnnotation eAnnotation = (EAnnotation) eContainer;
+
+			if (ANNOTATION_SOURCE__DUPLICATES.equals(eAnnotation.getSource())) {
+				eAnnotation = eAnnotation.getEAnnotation(eStructuralFeature
+					.getName());
+
+				if (eAnnotation != null) {
+					return eAnnotation.getDetails();
+				}
+			}
+		}
+
+		return ECollections.emptyEMap();
+	}
+
+	public static int getRedefinitionLowerBound(
+			EStructuralFeature eStructuralFeature) {
+		String lowerBound = getRedefinitionDetails(eStructuralFeature).get(
+			EcorePackage.Literals.ETYPED_ELEMENT__LOWER_BOUND.getName());
+
+		try {
+			return Integer.parseInt(lowerBound);
+		} catch (Exception e) {
+			// do nothing
+		}
+
+		return eStructuralFeature.getLowerBound();
+	}
+
+	public static int getRedefinitionUpperBound(EStructuralFeature eStructuralFeature) {
+		String upperBound = getRedefinitionDetails(eStructuralFeature).get(
+			EcorePackage.Literals.ETYPED_ELEMENT__UPPER_BOUND.getName());
+
+		try {
+			return Integer.parseInt(upperBound);
+		} catch (Exception e) {
+			// do nothing
+		}
+
+		return eStructuralFeature.getUpperBound();
+	}
+
+	public static EClassifier getRedefinitionEType(
+			EStructuralFeature eStructuralFeature) {
+		final String eType = getRedefinitionDetails(eStructuralFeature).get(
+			EcorePackage.Literals.ETYPED_ELEMENT__ETYPE.getName());
+
+		if (eType != null) {
+			ResourceSet resourceSet = UML2Util
+				.getResourceSet(eStructuralFeature);
+
+			if (resourceSet != null) {
+				Collection<EClassifier> eClassifiers = UML2Util
+					.findENamedElements(resourceSet, eType, "::", false, //$NON-NLS-1$
+						EcorePackage.Literals.ECLASSIFIER);
+
+				if (eClassifiers.size() == 1) {
+					return eClassifiers.iterator().next();
+				}
+			}
+		}
+
+		return eStructuralFeature.getEType();
+	}
+
 	public static boolean isSubset(EStructuralFeature eStructuralFeature) {
 		return null != eStructuralFeature
 			.getEAnnotation(ANNOTATION_SOURCE__SUBSETS);
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenFeature.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenFeature.java
index 6e12b4c..61a4e2a 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenFeature.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenFeature.java
@@ -8,7 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 208016
- *   Kenn Hussey (CEA) - 394623
+ *   Kenn Hussey (CEA) - 394623, 212765
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel;
@@ -16,6 +16,7 @@
 import java.util.List;
 
 import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
 
 /**
  * <!-- begin-user-doc -->
@@ -213,4 +214,19 @@
 	 */
 	List<org.eclipse.emf.codegen.ecore.genmodel.GenFeature> getAllSubsettedUnionGenFeatures();
 
+	/**
+	 * @since 1.9
+	 */
+	String getRedefinitionLowerBound();
+
+	/**
+	 * @since 1.9
+	 */
+	String getRedefinitionUpperBound();
+
+	/**
+	 * @since 1.9
+	 */
+	GenClassifier getRedefinitionTypeGenClassifier();
+
 } // GenFeature
\ No newline at end of file
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenPackage.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenPackage.java
index f6c080f..e23c6d9 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenPackage.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/GenPackage.java
@@ -7,7 +7,7 @@
  *
  * Contributors:
  *   IBM - initial API and implementation
- *   Kenn Hussey (CEA) - 394623
+ *   Kenn Hussey (CEA) - 394623, 212765
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel;
@@ -119,4 +119,9 @@
 	 */
 	List<org.eclipse.emf.codegen.ecore.genmodel.GenClass> getDerivedUnionAdapterGenClasses();
 
+	/**
+	 * @since 1.9
+	 */
+	boolean hasMultiplicityRedefinitions();
+
 } // GenPackage
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenFeatureImpl.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenFeatureImpl.java
index f47cce6..5954886 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenFeatureImpl.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenFeatureImpl.java
@@ -9,7 +9,7 @@
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 208016, 247980
  *   Kenn Hussey - 286329, 323181
- *   Kenn Hussey (CEA) - 394623
+ *   Kenn Hussey (CEA) - 394623, 212765
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.impl;
@@ -19,6 +19,7 @@
 import java.util.List;
 
 import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
 import org.eclipse.emf.codegen.ecore.genmodel.GenJDKLevel;
 import org.eclipse.emf.codegen.ecore.genmodel.GenOperation;
 import org.eclipse.emf.codegen.ecore.genmodel.GenRuntimeVersion;
@@ -861,4 +862,19 @@
 		return allSubsettedGenFeatures;
 	}
 
+	public String getRedefinitionLowerBound() {
+		return String.valueOf(Generator
+			.getRedefinitionLowerBound(getEcoreFeature()));
+	}
+
+	public String getRedefinitionUpperBound() {
+		return String.valueOf(Generator
+			.getRedefinitionUpperBound(getEcoreFeature()));
+	}
+
+	public GenClassifier getRedefinitionTypeGenClassifier() {
+		return findGenClassifier(Generator
+			.getRedefinitionEType(getEcoreFeature()));
+	}
+
 } // GenFeatureImpl
diff --git a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenPackageImpl.java b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenPackageImpl.java
index 2d7ab3b..3099a36 100644
--- a/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenPackageImpl.java
+++ b/plugins/org.eclipse.uml2.codegen.ecore/src/org/eclipse/uml2/codegen/ecore/genmodel/impl/GenPackageImpl.java
@@ -8,7 +8,7 @@
  * Contributors:
  *   IBM - initial API and implementation
  *   Kenn Hussey (Embarcadero Technologies) - 247980
- *   Kenn Hussey (CEA) - 394623
+ *   Kenn Hussey (CEA) - 394623, 212765
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.impl;
@@ -19,10 +19,14 @@
 import org.eclipse.emf.codegen.ecore.genmodel.GenResourceKind;
 
 import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.util.EMap;
 
+import org.eclipse.emf.ecore.EAnnotation;
 import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EcorePackage;
 import org.eclipse.emf.ecore.impl.ENotificationImpl;
 
+import org.eclipse.uml2.codegen.ecore.Generator;
 import org.eclipse.uml2.codegen.ecore.genmodel.GenBase;
 import org.eclipse.uml2.codegen.ecore.genmodel.GenModelPackage;
 import org.eclipse.uml2.codegen.ecore.genmodel.GenPackage;
@@ -387,4 +391,33 @@
 		});
 	}
 
+	public boolean hasMultiplicityRedefinitions() {
+
+		for (GenClass genClass : getGenClasses()) {
+			EAnnotation duplicatesAnnotation = genClass.getEcoreClass()
+				.getEAnnotation(Generator.ANNOTATION_SOURCE__DUPLICATES);
+
+			if (duplicatesAnnotation != null) {
+
+				for (EAnnotation eAnnotation : duplicatesAnnotation
+					.getEAnnotations()) {
+
+					EMap<String, String> details = eAnnotation.getDetails();
+
+					if (details
+						.containsKey(EcorePackage.Literals.ETYPED_ELEMENT__LOWER_BOUND
+							.getName())
+						|| details
+							.containsKey(EcorePackage.Literals.ETYPED_ELEMENT__UPPER_BOUND
+								.getName())) {
+
+						return true;
+					}
+				}
+			}
+		}
+
+		return false;
+	}
+
 } // GenPackageImpl
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 194ee51..7b19838 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
  *   Kenn Hussey (Embarcadero Technologies) - 208016, 206636
- *   Kenn Hussey (CEA) - 394623
+ *   Kenn Hussey (CEA) - 394623, 212765
  *
  */
 package org.eclipse.uml2.codegen.ecore.genmodel.util;
@@ -19,6 +19,7 @@
 import org.eclipse.emf.codegen.ecore.genmodel.GenAnnotation;
 import org.eclipse.emf.codegen.ecore.genmodel.GenBase;
 import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
 import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
 import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
 import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
@@ -202,6 +203,16 @@
 			: Collections.<GenClass> emptyList();
 	}
 
+	/**
+	 * @since 1.9
+	 */
+	public static boolean hasMultiplicityRedefinitions(GenPackage genPackage) {
+		return genPackage instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenPackage
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenPackage) genPackage)
+				.hasMultiplicityRedefinitions()
+			: false;
+	}
+
 	// GenClass utilities
 
 	public static String getOperationsClassName(GenClass genClass) {
@@ -870,6 +881,37 @@
 			: Collections.<GenFeature> emptyList();
 	}
 
+	/**
+	 * @since 1.9
+	 */
+	public static String getRedefinitionLowerBound(GenFeature genFeature) {
+		return genFeature instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenFeature
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenFeature) genFeature)
+				.getRedefinitionLowerBound()
+			: genFeature.getLowerBound();
+	}
+
+	/**
+	 * @since 1.9
+	 */
+	public static String getRedefinitionUpperBound(GenFeature genFeature) {
+		return genFeature instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenFeature
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenFeature) genFeature)
+				.getRedefinitionUpperBound()
+			: genFeature.getUpperBound();
+	}
+
+	/**
+	 * @since 1.9
+	 */
+	public static GenClassifier getRedefinitionTypeGenClassifier(
+			GenFeature genFeature) {
+		return genFeature instanceof org.eclipse.uml2.codegen.ecore.genmodel.GenFeature
+			? ((org.eclipse.uml2.codegen.ecore.genmodel.GenFeature) genFeature)
+				.getRedefinitionTypeGenClassifier()
+			: genFeature.getTypeGenClassifier();
+	}
+
 	// GenOperation utilities
 
 	public static boolean isCached(GenOperation genOperation) {