@@ -19,6 +19,7 @@ import static jce.properties.TextProperty.WRAPPER_SUFFIX
1919import org.eclipse.emf.ecore.InternalEObject
2020import org.eclipse.emf.ecore.EObject
2121import org.eclipse.emf.common.notify.Notifier
22+ import jce.util.EcoreToJavaUtil
2223
2324/**
2425 * This class models a wrapper class which unifies an origin code type with its Ecore counterparts in the Ecore model
@@ -57,7 +58,7 @@ class WrapperRepresentation {
5758 ecoreImplementation = append(ECORE_PACKAGE . get, packageName, " impl" , eClass. name + " Impl" )
5859 typeParameters = TypeParameterGenerator . generate(eClass. ETypeParameters , ecoreImplementation, project, properties)
5960 importDeclarations = new HashSet // add import declarations:
60- if (superClass == = null ) {
61+ if (superClass == = null ) {
6162 importDeclarations + = InternalEObject . name
6263 importDeclarations + = EObject . name
6364 importDeclarations + = Notifier . name
@@ -87,10 +88,12 @@ class WrapperRepresentation {
8788 @DelegateExcept («Notifier . simpleName», «EObject . simpleName»)
8889 protected var «InternalEObject . simpleName» internalEcoreImplementation
8990 «ENDIF »
90-
91+
9192 «constructors»
9293
9394 «instanceMethod»
95+
96+ «specialSetters»
9497 }
9598 ' ' '
9699
@@ -166,6 +169,10 @@ class WrapperRepresentation {
166169 «FOR importDeclaration : importDeclarations»
167170 import «importDeclaration»
168171 «ENDFOR »
172+
173+ «IF eClass. EStructuralFeatures . exists[field | field. upperBound == - 1 ]»
174+ import java.util. List
175+ «ENDIF »
169176 ' ' '
170177
171178 /**
@@ -186,6 +193,21 @@ class WrapperRepresentation {
186193 */
187194 def private String getMethodKeyword() ' ' ' «IF superClass == = null »def«ELSE »override«ENDIF »' ' '
188195
196+ /**
197+ * Returns a special setter for every field which was extracted using multiplicities.
198+ */
199+ def private String getSpecialSetters() ' ' '
200+ «FOR field : eClass. EStructuralFeatures »
201+ «IF field. upperBound == - 1 »
202+ def protected void set«field.name.toFirstUpper» (List<«EcoreToJavaUtil.getFeatureType (field. EGenericType )»> «field.name») {
203+ get«field. name. toFirstUpper». clear
204+ get«field. name. toFirstUpper». addAll(«field. name»)
205+ }
206+
207+ «ENDIF »
208+ «ENDFOR »
209+ ' ' ' // TODO (HIGH) imports
210+
189211 /**
190212 * Returns the fully qualified name of the super class of an EClass.
191213 */
@@ -200,7 +222,7 @@ class WrapperRepresentation {
200222 /**
201223 * Generates the String of type type parameters with their respective bounds, e.g. "<T extends List<EString> & IFace<List<EString>>>"
202224 */
203- def private String getTypeParameters() { // TODO (MEDIUM ) remove duplicate code.
225+ def private String getTypeParameters() { // TODO (HIGH ) remove duplicate code.
204226 if(typeParameters.empty) {
205227 return ""
206228 }
@@ -211,7 +233,7 @@ class WrapperRepresentation {
211233 return ' ' ' < «joiner»> ' ' '
212234 }
213235
214- def private String getGenericArguments() { // TODO (MEDIUM ) remove duplicate code.
236+ def private String getGenericArguments() { // TODO (HIGH ) remove duplicate code.
215237 if(typeParameters.empty) {
216238 return ""
217239 }
0 commit comments