/
DerivedUnionAdapterClass.javajet
144 lines (135 loc) · 5.32 KB
/
DerivedUnionAdapterClass.javajet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<%@ jet package="org.eclipse.uml2.codegen.ecore.templates.model" imports="java.util.* org.eclipse.emf.codegen.ecore.genmodel.* org.eclipse.uml2.codegen.ecore.genmodel.util.UML2GenModelUtil" class="DerivedUnionAdapterClass" %>
<%
/**
* <copyright>
*
* Copyright (c) 2013, 2018 CEA and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Kenn Hussey (CEA) - initial API and implementation
* Kenn Hussey - 535301
*
* </copyright>
*/
%>
<%GenPackage genPackage = (GenPackage)argument; GenModel genModel = genPackage.getGenModel();%>
<%@ include file="../Header.javajetinc"%>
package <%=genPackage.getUtilitiesPackageName()%>;
<%genModel.markImportLocation(stringBuffer);%>
/**
* <!-- begin-user-doc -->
* An adapter that propagates notifications for derived unions.
* <!-- end-user-doc -->
* @see <%=genPackage.getQualifiedPackageInterfaceName()%>
* @generated
*/
public class <%=UML2GenModelUtil.getDerivedUnionAdapterClassName(genPackage)%> extends <%=genModel.getImportedName("org.eclipse.emf.common.notify.impl.AdapterImpl")%>
{
<%if (genModel.hasCopyrightField()) {%>
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final <%=genModel.getImportedName("java.lang.String")%> copyright = <%=genModel.getCopyrightFieldLiteral()%>;<%=genModel.getNonNLS()%>
<%}%>
/**
* The cached model package.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static <%=genPackage.getImportedPackageInterfaceName()%> modelPackage;
/**
* Creates an instance of the adapter.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public <%=UML2GenModelUtil.getDerivedUnionAdapterClassName(genPackage)%>()
{
if (modelPackage == null)
{
modelPackage = <%=genPackage.getImportedPackageInterfaceName()%>.eINSTANCE;
}
}
/**
* Calls <code>notifyChanged</code> with the appropriate model class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param notification a description of the change.
* @generated
*/
public void notifyChanged(<%=genModel.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification)
{
Object notifier = notification.getNotifier();
if (notifier instanceof <%=genModel.getImportedName("org.eclipse.emf.ecore.EObject")%>)
{
<%=genModel.getImportedName("org.eclipse.emf.ecore.EClass")%> eClass = ((<%=genModel.getImportedName("org.eclipse.emf.ecore.EObject")%>)notifier).eClass();
if (eClass.eContainer() == modelPackage)
{
notifyChanged(notification, eClass);
}
}
}
/**
* Calls <code>notifyXXXChanged</code> for the corresponding class of the model.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param notification a description of the change.
* @param eClass the Ecore class of the notifier.
* @generated
*/
protected void notifyChanged(<%=genModel.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification, <%=genModel.getImportedName("org.eclipse.emf.ecore.EClass")%> eClass)
{
switch (eClass.getClassifierID())
{
<%for (GenClass genClass : UML2GenModelUtil.getDerivedUnionAdapterGenClasses(genPackage)) {%>
case <%=genPackage.getImportedPackageInterfaceName()%>.<%=genPackage.getClassifierID(genClass)%>:
notify<%=genClass.getName()%>Changed(notification, eClass);
break;
<%}%>
}
}
/**
* Does nothing; clients may override so that it does something.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param notification a description of the change.
* @param eClass the Ecore class of the notifier.
* @param derivedUnion the derived union affected by the change.
* @generated
*/
public void notifyChanged(<%=genModel.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification, <%=genModel.getImportedName("org.eclipse.emf.ecore.EClass")%> eClass, <%=genModel.getImportedName("org.eclipse.emf.ecore.EStructuralFeature")%> derivedUnion)
{
// Do nothing.
}
<%for (GenClass genClass : UML2GenModelUtil.getDerivedUnionAdapterGenClasses(genPackage)) {%>
/**
* Calls <code>notifyChanged</code> for each affected derived union.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param notification a description of the change.
* @param eClass the Ecore class of the notifier.
* @generated
*/
protected void notify<%=genClass.getName()%>Changed(<%=genModel.getImportedName("org.eclipse.emf.common.notify.Notification")%> notification, <%=genModel.getImportedName("org.eclipse.emf.ecore.EClass")%> eClass)
{
switch (notification.getFeatureID(<%=genClass.getRawImportedInterfaceName()%>.class))
{
<%for (GenFeature genFeature : genClass.getAllGenFeatures()) { List<GenFeature> allSubsettedUnionGenFeatures = UML2GenModelUtil.getAllSubsettedUnionGenFeatures(genFeature); if (!allSubsettedUnionGenFeatures.isEmpty()) {%>
case <%=genClass.getQualifiedFeatureID(genFeature)%>:
<%for (GenFeature subsettedUnionGenFeature : allSubsettedUnionGenFeatures) {%>
notifyChanged(notification, eClass, <%=subsettedUnionGenFeature.getQualifiedFeatureAccessor()%>);
<%}%>
break;
<%}}%>
}
}
<%}%>
} //<%=UML2GenModelUtil.getDerivedUnionAdapterClassName(genPackage)%>
<%genModel.emitSortedImports();%>