Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java')
-rw-r--r--extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java152
1 files changed, 99 insertions, 53 deletions
diff --git a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java
index fcec17be87a..21372aa2d6c 100644
--- a/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java
+++ b/extraplugins/facade/org.eclipse.papyrus.facade.codegen/src/org/eclipse/papyrus/facade/codegen/utils/WrappingListUtils.java
@@ -1,3 +1,16 @@
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
package org.eclipse.papyrus.facade.codegen.utils;
import java.util.ArrayList;
@@ -19,13 +32,20 @@ import org.eclipse.emf.ecore.EStructuralFeature;
public class WrappingListUtils {
- private static final String UNSUPPORTED_LIST_CONSTRUCTOR = "UNSUPPORTED_LIST_CONSTRUCTOR";
+ private static final String UNSUPPORTED_LIST_CONSTRUCTOR = "UNSUPPORTED_LIST_CONSTRUCTOR"; //$NON-NLS-1$
+ /**
+ * Gets the list of genFeatures that are subsetted by the genFeature.
+ *
+ * @param genFeature
+ * the genFeature
+ * @return the list of subsetted genFeatures
+ */
protected static List<GenFeature> getSubsetReferenceGenFeature(GenFeature genFeature) {
List<GenFeature> result = new ArrayList<GenFeature>();
EStructuralFeature ecoreFeature = genFeature.getEcoreFeature();
if(ecoreFeature != null) {
- EAnnotation annotation = ecoreFeature.getEAnnotation("subsets");
+ EAnnotation annotation = ecoreFeature.getEAnnotation("subsets"); //$NON-NLS-1$
if(annotation != null) {
EList<EObject> references = annotation.getReferences();
for(EObject ref : references) {
@@ -40,6 +60,18 @@ public class WrappingListUtils {
return result;
}
+
+ /**
+ * Gets the wrapping list constructor.
+ *
+ * @param genClass
+ * the gen class
+ * @param genFeature
+ * the gen feature
+ * @param typeArgument
+ * the type argument
+ * @return the wrapping list constructor
+ */
public static String getWrappingListConstructor(GenClass genClass, GenFeature genFeature, String typeArgument) {
boolean isJava5 = isJDK50(genClass.getGenModel());
@@ -48,12 +80,12 @@ public class WrappingListUtils {
GenClassImpl genClassImpl = (GenClassImpl)genClass;
StringBuffer sb = new StringBuffer();
- String unsettable = genFeature.isUnsettable() ? ".Unsettable" : "";
- String offsetCorrectionField = genClassImpl.hasOffsetCorrection() ? " + " + genClassImpl.getOffsetCorrectionField(null) : "";
+ String unsettable = genFeature.isUnsettable() ? ".Unsettable" : ""; //$NON-NLS-1$ //$NON-NLS-2$
+ String offsetCorrectionField = genClassImpl.hasOffsetCorrection() ? " + " + genClassImpl.getOffsetCorrectionField(null) : ""; //$NON-NLS-1$ //$NON-NLS-2$
if(genFeature.isMapType()) {
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_MapType");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_MapType"); //$NON-NLS-1$
// GenClass mapGenClass = genFeature.getMapEntryTypeGenClass();
// sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EcoreEMap"));
// sb.append(unsettable);
@@ -77,7 +109,7 @@ public class WrappingListUtils {
// }
// sb.append(")");
} else if(genFeature.isFeatureMapType()) {
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_FeatureMapType");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_FeatureMapType"); //$NON-NLS-1$
// if(genFeature.isWrappedFeatureMapType()) {
// sb.append(genFeature.getImportedEffectiveFeatureMapWrapperClass());
// sb.append("(new ");
@@ -94,7 +126,7 @@ public class WrappingListUtils {
EGenericType eGenericType = genFeature.getEcoreFeature().getEGenericType();
if(genClassImpl.getGenModel().isSuppressNotification()) {
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Generic");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Generic"); //$NON-NLS-1$
// sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.BasicInternalEList"));
// if(genClassImpl.getGenModel().getRuntimeVersion().getValue() >= GenRuntimeVersion.EMF28_VALUE) {
@@ -112,66 +144,66 @@ public class WrappingListUtils {
if(genFeature.isBidirectional()) {
GenFeature reverseFeature = genFeature.getReverse();
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectContainmentWithInverseEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectContainmentWithInverseEList")); //$NON-NLS-1$
} else {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectContainmentWithInverseEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectContainmentWithInverseEList")); //$NON-NLS-1$
}
sb.append(unsettable);
if(genFeature.isResolveProxies()) {
// sb.append(".Resolving");
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Resolving");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Resolving"); //$NON-NLS-1$
}
if(isJava5) {
sb.append('<');
sb.append(genFeature.getListItemType(genClassImpl));
sb.append('>');
}
- sb.append("(");
+ sb.append("("); //$NON-NLS-1$
sb.append(typeArgument);
- sb.append(".class, this, ");
+ sb.append(".class, this, "); //$NON-NLS-1$
sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
sb.append(offsetCorrectionField);
- sb.append(", ");
+ sb.append(", "); //$NON-NLS-1$
sb.append(reverseFeature.getGenClass().getQualifiedFeatureID(reverseFeature));
if(reverseFeature.getGenClass().hasOffsetCorrection()) {
- sb.append(" + ");
+ sb.append(" + "); //$NON-NLS-1$
sb.append(genClassImpl.getOffsetCorrectionField(genFeature));
}
- sb.append(",(java.util.Collection)umlList");
+ sb.append(",(java.util.Collection)umlList"); //$NON-NLS-1$
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
- sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
- sb.append(")");
+ sb.append(")"); //$NON-NLS-1$
} else {
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectContainmentEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectContainmentEList")); //$NON-NLS-1$
} else {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectContainmentEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectContainmentEList")); //$NON-NLS-1$
}
sb.append(unsettable);
if(genFeature.isResolveProxies()) {
// sb.append(".Resolving");
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Resolving");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_Resolving"); //$NON-NLS-1$
}
if(isJava5) {
sb.append('<');
sb.append(genFeature.getListItemType(genClassImpl));
sb.append('>');
}
- sb.append("(");
+ sb.append("("); //$NON-NLS-1$
sb.append(typeArgument);
- sb.append(".class, this, ");
+ sb.append(".class, this, "); //$NON-NLS-1$
sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
sb.append(offsetCorrectionField);
- sb.append(",(java.util.Collection)umlList");
+ sb.append(",(java.util.Collection)umlList"); //$NON-NLS-1$
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
- sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
- sb.append(")");
+ sb.append(")"); //$NON-NLS-1$
}
} else if(genFeature.isReferenceType()) {
if(genFeature.isBidirectional()) {
@@ -179,23 +211,23 @@ public class WrappingListUtils {
if(genFeature.isResolveProxies()) {
// sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList"));
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectWithInverseEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectWithInverseEList")); //$NON-NLS-1$
} else {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectWithInverseEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectWithInverseEList")); //$NON-NLS-1$
}
} else {
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectWithInverseEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectWithInverseEList")); //$NON-NLS-1$
} else {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectWithInverseEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectWithInverseEList")); //$NON-NLS-1$
}
}
sb.append(unsettable);
if(reverseFeature.isListType()) {
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(".WrappingSubsetManyInverse");
+ sb.append(".WrappingSubsetManyInverse"); //$NON-NLS-1$
} else {
- sb.append(".WrappingManyInverse");
+ sb.append(".WrappingManyInverse"); //$NON-NLS-1$
}
}
if(isJava5) {
@@ -203,37 +235,37 @@ public class WrappingListUtils {
sb.append(genFeature.getListItemType(genClassImpl));
sb.append('>');
}
- sb.append("(");
+ sb.append("("); //$NON-NLS-1$
sb.append(typeArgument);
- sb.append(".class, this, ");
+ sb.append(".class, this, "); //$NON-NLS-1$
sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
sb.append(offsetCorrectionField);
- sb.append(", ");
+ sb.append(", "); //$NON-NLS-1$
sb.append(reverseFeature.getGenClass().getQualifiedFeatureID(reverseFeature));
if(reverseFeature.getGenClass().hasOffsetCorrection()) {
- sb.append(" + ");
+ sb.append(" + "); //$NON-NLS-1$
sb.append(genClassImpl.getOffsetCorrectionField(genFeature));
}
- sb.append(",(java.util.Collection)umlList");
+ sb.append(",(java.util.Collection)umlList"); //$NON-NLS-1$
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
- sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
- sb.append(")");
+ sb.append(")"); //$NON-NLS-1$
} else {
if(genFeature.isResolveProxies()) {
// sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EObjectResolvingEList"));
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectEList")); //$NON-NLS-1$
} else {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectEList")); //$NON-NLS-1$
}
} else {
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.subset.WrappingSubsetEObjectEList")); //$NON-NLS-1$
} else {
- sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectEList"));
+ sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingEObjectEList")); //$NON-NLS-1$
}
}
sb.append(unsettable);
@@ -242,26 +274,26 @@ public class WrappingListUtils {
sb.append(genFeature.getListItemType(genClassImpl));
sb.append('>');
}
- sb.append("(");
+ sb.append("("); //$NON-NLS-1$
sb.append(typeArgument);
- sb.append(".class, this, ");
+ sb.append(".class, this, "); //$NON-NLS-1$
sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
sb.append(offsetCorrectionField);
- sb.append(",(java.util.Collection)umlList");
+ sb.append(",(java.util.Collection)umlList"); //$NON-NLS-1$
if(!getSubsetReferenceGenFeature(genFeature).isEmpty()) {
for(GenFeature feature : getSubsetReferenceGenFeature(genFeature)) {
- sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()");
+ sb.append(",(" + genClassImpl.getGenModel().getImportedName("org.eclipse.papyrus.facade.utils.wrappinglist.WrappingList") + ")" + feature.getGetAccessor() + "()"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
}
- sb.append(")");
+ sb.append(")"); //$NON-NLS-1$
}
} else { //data type
if(genFeature.isUnique()) {
// sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EDataTypeUniqueEList"));
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_UniqueDatatype");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_UniqueDatatype"); //$NON-NLS-1$
} else {
// sb.append(genClassImpl.getGenModel().getImportedName("org.eclipse.emf.ecore.util.EDataTypeEList"));
- sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_NotUniqueDatatype");
+ sb.append(UNSUPPORTED_LIST_CONSTRUCTOR + "_NotUniqueDatatype"); //$NON-NLS-1$
}
sb.append(unsettable);
if(isJava5) {
@@ -269,25 +301,39 @@ public class WrappingListUtils {
sb.append(genFeature.getListItemType(genClassImpl));
sb.append('>');
}
- sb.append("(");
+ sb.append("("); //$NON-NLS-1$
sb.append(isPrimitiveType(eGenericType.getERawType()) ? genFeature.getRawListItemType() : typeArgument);
- sb.append(".class, this, ");
+ sb.append(".class, this, "); //$NON-NLS-1$
sb.append(genClassImpl.getQualifiedFeatureID(genFeature));
sb.append(offsetCorrectionField);
- sb.append(")");
+ sb.append(")"); //$NON-NLS-1$
}
}
return sb.toString();
}
- return "";
+ return ""; //$NON-NLS-1$
}
+ /**
+ * Checks if the genModel is defined as JDK50 complianceLevel.
+ *
+ * @param genModel
+ * the genModel
+ * @return true, if the genModel is defined as JDK50 complianceLevel.
+ */
public static boolean isJDK50(GenModel genModel) {
if(genModel != null && genModel.getComplianceLevel() != null)
return genModel.getComplianceLevel().getValue() >= GenJDKLevel.JDK50;
return false;
}
+ /**
+ * Checks if is primitive type.
+ *
+ * @param eType
+ * the eType
+ * @return true, if is primitive type
+ */
static public boolean isPrimitiveType(EClassifier eType) {
return eType != null && CodeGenUtil.isJavaPrimitiveType(eType.getInstanceClassName());
}

Back to the top