22 * Initial version copyright 2008 Lockheed Martin Corporation, except
33 * as stated in the file entitled Licensing-Information.
44 *
5- * All modifications copyright 2009-2012 Data Access Technologies, Inc.
5+ * Modifications:
6+ * Copyright 2009-2012 Data Access Technologies, Inc.
7+ * Copyright 2020 Model Driven Solutions, Inc.
68 *
79 * Licensed under the Academic Free License version 3.0
810 * (http://www.opensource.org/licenses/afl-3.0.php), except as stated
@@ -34,7 +36,7 @@ public ClassifierFactory(org.modeldriven.fuml.test.builtin.environment.TestEnvir
3436 this .environment = environment ;
3537 } // ClassifierFactory
3638
37- public void createEnumerationType (String typeName , int numberOfLiterals ) {
39+ public Enumeration createEnumerationType (String typeName , int numberOfLiterals ) {
3840 Enumeration type = new Enumeration ();
3941
4042 type .setName (typeName );
@@ -47,30 +49,36 @@ public void createEnumerationType(String typeName, int numberOfLiterals) {
4749 }
4850
4951 environment .addElement (type );
52+
53+ return type ;
5054 } // createEnumerationType
5155
52- public void createDataType (String name ) {
56+ public DataType createDataType (String name ) {
5357 DataType dataType = new DataType ();
5458 dataType .setName (name );
5559 environment .addElement (dataType );
60+ return dataType ;
5661 } // createDataType
5762
58- public void createClass (String name ) {
63+ public Class_ createClass (String name ) {
5964 Class_ class_ = new Class_ ();
6065 class_ .setName (name );
6166 environment .addElement (class_ );
67+ return class_ ;
6268 } // createClass
6369
64- public void createSignal (String name ) {
70+ public Signal createSignal (String name ) {
6571 Signal signal = new Signal ();
6672 signal .setName (name );
6773 this .environment .addElement (signal );
74+ return signal ;
6875 } // createSignal
6976
70- public void createAssociation (String name ) {
77+ public Association createAssociation (String name ) {
7178 Association association = new Association ();
7279 association .setName (name );
7380 environment .addElement (association );
81+ return association ;
7482 } // createAssociation
7583
7684 public Property addAttribute (String classifierName , String attributeName ,
@@ -130,14 +138,14 @@ public Property addAttribute(String classifierName, String attributeName,
130138 return attribute ;
131139 } // addAttribute
132140
133- public void addEnd (String associationName , String endName ,
141+ public Property addEnd (String associationName , String endName ,
134142 String endTypeName , boolean isComposite ) {
135143 Classifier type = environment .getType (associationName );
136144
137145 if (type == null || !(type instanceof Association )) {
138146 Debug .println ("[addEnd] " + associationName
139147 + " not found or not an association." );
140- return ;
148+ return null ;
141149 }
142150
143151 Association association = (Association ) type ;
@@ -147,7 +155,7 @@ public void addEnd(String associationName, String endName,
147155 if (endType == null ) {
148156 Debug .println ("[addEnd] " + endTypeName
149157 + " not found or not a classifier." );
150- return ;
158+ return null ;
151159 }
152160
153161 Property end = new Property ();
@@ -165,16 +173,18 @@ public void addEnd(String associationName, String endName,
165173 }
166174
167175 association .addOwnedEnd (end );
168-
176+ association .addNavigableOwnedEnd (end );
177+
178+ return end ;
169179 } // addEnd
170180
171- public void addClassifierBehavior (String className , String behaviorName ) {
181+ public Class_ addClassifierBehavior (String className , String behaviorName ) {
172182 NamedElement element = this .environment .getElement (className );
173183
174184 if (element == null || !(element instanceof Class_ )) {
175185 Debug .println ("[addClassifierBehavior] " + className
176186 + " not found or not a class." );
177- return ;
187+ return null ;
178188 }
179189
180190 Class_ classifier = (Class_ ) element ;
@@ -184,25 +194,26 @@ public void addClassifierBehavior(String className, String behaviorName) {
184194 if (element == null || !(element instanceof Behavior )) {
185195 Debug .println ("[addClassifierBehavior] " + behaviorName
186196 + " not found or not a behavior." );
187- return ;
197+ return null ;
188198 }
189199
190200 Behavior behavior = (Behavior ) element ;
191201 this .environment .removeElement (element );
192202
193203 classifier .addOwnedBehavior (behavior );
194204 classifier .setClassifierBehavior (behavior );
195-
205+
206+ return classifier ;
196207 } // addClassifierBehavior
197208
198- public void addOperation (String className , String baseClassName ,
209+ public Operation addOperation (String className , String baseClassName ,
199210 String operationName , String methodName ) {
200211 NamedElement element = this .environment .getElement (className );
201212
202213 if (element == null || !(element instanceof Class_ )) {
203214 Debug .println ("[addOperation] " + className
204215 + " not found or not a class." );
205- return ;
216+ return null ;
206217 }
207218
208219 Class_ classifier = (Class_ ) element ;
@@ -216,7 +227,7 @@ public void addOperation(String className, String baseClassName,
216227 if (element == null || !(element instanceof Class_ )) {
217228 Debug .println ("[addOperation] " + baseClassName
218229 + " not found or not a class." );
219- return ;
230+ return null ;
220231 }
221232
222233 Class_ baseClass = (Class_ ) element ;
@@ -226,7 +237,7 @@ public void addOperation(String className, String baseClassName,
226237 if (redefinedOperation == null ) {
227238 Debug .println ("[addOperation] " + operationName
228239 + " is not an operation of " + baseClassName + "." );
229- return ;
240+ return null ;
230241 }
231242
232243 operation .addRedefinedOperation (redefinedOperation );
@@ -240,7 +251,7 @@ public void addOperation(String className, String baseClassName,
240251 if (element == null || !(element instanceof Behavior )) {
241252 Debug .println ("[addOperation] " + methodName
242253 + " not found or not a behavior." );
243- return ;
254+ return null ;
244255 }
245256
246257 Behavior behavior = (Behavior ) element ;
@@ -251,33 +262,35 @@ public void addOperation(String className, String baseClassName,
251262 }
252263
253264 classifier .addOwnedOperation (operation );
254-
265+
266+ return operation ;
255267 } // addOperation
256268
257- public void addGeneralization (String subtypeName , String supertypeName ) {
269+ public Generalization addGeneralization (String subtypeName , String supertypeName ) {
258270 Classifier subtype = this .environment .getType (subtypeName );
259271
260272 if (subtype == null ) {
261273 Debug .println ("[addGeneralization] " + subtypeName
262274 + " not found or not a classifier." );
263- return ;
275+ return null ;
264276 }
265277
266278 Classifier supertype = this .environment .getType (supertypeName );
267279
268280 if (supertype == null ) {
269281 Debug .println ("[addGeneralization] " + supertypeName
270282 + " not found or not a classifier." );
271- return ;
283+ return null ;
272284 }
273285
274286 Generalization generalization = new Generalization ();
275287 generalization .setGeneral (supertype );
276288 subtype .addGeneralization (generalization );
289+
290+ return generalization ;
277291 } // addGeneralization
278292
279- protected fuml .syntax .classification .Operation getOperation (
280- fuml .syntax .structuredclassifiers .Class_ class_ , String operationName ) {
293+ protected Operation getOperation (Class_ class_ , String operationName ) {
281294 for (int i = 0 ; i < class_ .member .size (); i ++) {
282295 NamedElement member = class_ .member .getValue (i );
283296 if (member .name .equals (operationName )) {
0 commit comments