Skip to content

Commit c1390c5

Browse files
committed
Issue #12 - Resolved.
- Implemented generic wrapping of non-class classifiers as instances of Classifier, rather than NamedElement.
1 parent 7bb7d59 commit c1390c5

File tree

6 files changed

+42
-14
lines changed

6 files changed

+42
-14
lines changed
84 Bytes
Binary file not shown.

org.modeldriven.alf.eclipse/src/org/modeldriven/alf/eclipse/uml/Element.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ public static Element wrap(org.eclipse.uml2.uml.Element base) {
4141
if (base == null) {
4242
return null;
4343
}
44-
Element newInstance = (Element)factory.newInstanceFor(base,
45-
org.eclipse.uml2.uml.Behavior.class,
46-
org.eclipse.uml2.uml.Class.class,
47-
org.eclipse.uml2.uml.NamedElement.class);
44+
Element newInstance = (Element)factory.newInstanceFor(base);
4845
if (newInstance != null) {
4946
newInstance.setBase(base);
5047
}

org.modeldriven.alf.eclipse/src/org/modeldriven/alf/eclipse/uml/ElementFactory.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -9,4 +9,13 @@
99
package org.modeldriven.alf.eclipse.uml;
1010

1111
public class ElementFactory extends org.modeldriven.alf.uml.ElementFactory {
12+
13+
public ElementFactory() {
14+
super(
15+
org.eclipse.uml2.uml.Behavior.class,
16+
org.eclipse.uml2.uml.Class.class,
17+
org.eclipse.uml2.uml.Classifier.class,
18+
org.eclipse.uml2.uml.NamedElement.class);
19+
}
20+
1221
}

org.modeldriven.alf.fuml.impl/src/org/modeldriven/alf/fuml/impl/uml/ElementFactory.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -9,4 +9,13 @@
99
package org.modeldriven.alf.fuml.impl.uml;
1010

1111
public class ElementFactory extends org.modeldriven.alf.uml.ElementFactory {
12+
13+
public ElementFactory() {
14+
super(
15+
fUML.Syntax.CommonBehaviors.BasicBehaviors.Behavior.class,
16+
fUML.Syntax.Classes.Kernel.Class_.class,
17+
fUML.Syntax.Classes.Kernel.Classifier.class,
18+
fUML.Syntax.Classes.Kernel.NamedElement.class);
19+
}
20+
1221
}
84 Bytes
Binary file not shown.

org.modeldriven.alf/src/org/modeldriven/alf/uml/ElementFactory.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright 2011-2015 Data Access Technologies, Inc. (Model Driven Solutions)
2+
* Copyright 2011-2016 Data Access Technologies, Inc. (Model Driven Solutions)
33
* All rights reserved worldwide. This program and the accompanying materials
44
* are made available for use under the terms of the GNU General Public License
55
* (GPL) version 3 that accompanies this distribution and is available at
@@ -13,6 +13,22 @@
1313

1414
public abstract class ElementFactory {
1515

16+
private Class<?> behaviorClass = null;
17+
private Class<?> classClass = null;
18+
private Class<?> classifierClass = null;
19+
private Class<?> namedElementClass = null;
20+
21+
public ElementFactory(
22+
Class<?> behaviorClass,
23+
Class<?> classClass,
24+
Class<?> classifierClass,
25+
Class<?> namedElementClass) {
26+
this.behaviorClass = behaviorClass;
27+
this.classClass = classClass;
28+
this.classifierClass = classifierClass;
29+
this.namedElementClass = namedElementClass;
30+
}
31+
1632
@SuppressWarnings("unchecked")
1733
public <T extends org.modeldriven.alf.uml.Element> T newInstance(Class<T> class_) {
1834
final String className = class_.getSimpleName();
@@ -27,18 +43,15 @@ public <T extends org.modeldriven.alf.uml.Element> T newInstance(Class<T> class_
2743
}
2844

2945
public Element newInstanceFor(Object base) {
30-
return this.newInstanceFor(base.getClass().getSimpleName(), base);
31-
}
32-
33-
public Element newInstanceFor(Object base, Class<?> behaviorClass, Class<?> classClass, Class<?> namedElementClass) {
3446
Element newInstance = null;
3547
try {
3648
newInstance = (Element)this.createInstanceFor(base.getClass().getSimpleName(), base);
3749
} catch (Exception e) {
3850
final String className =
39-
behaviorClass.isInstance(base)? "Behavior":
40-
classClass.isInstance(base)? "Class":
41-
namedElementClass.isInstance(base)? "NamedElement":
51+
this.behaviorClass.isInstance(base)? "Behavior":
52+
this.classClass.isInstance(base)? "Class":
53+
this.classifierClass.isInstance(base)? "Classifier":
54+
this.namedElementClass.isInstance(base)? "NamedElement":
4255
"Element";
4356
newInstance = (Element)this.newInstanceFor(className, base);
4457
}

0 commit comments

Comments
 (0)