3 package org.opendaylight.nemo.tool.eclipse.plugin.editor.util;
5 import org.eclipse.emf.ecore.EObject;
6 import org.eclipse.emf.ecore.EPackage;
8 import org.eclipse.emf.ecore.util.Switch;
10 import org.opendaylight.nemo.tool.eclipse.plugin.editor.*;
13 * <!-- begin-user-doc -->
14 * The <b>Switch</b> for the model's inheritance hierarchy.
15 * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
16 * to invoke the <code>caseXXX</code> method for each class of the model,
17 * starting with the actual class of the object
18 * and proceeding up the inheritance hierarchy
19 * until a non-null result is returned,
20 * which is the result of the switch.
21 * <!-- end-user-doc -->
22 * @see org.opendaylight.nemo.tool.eclipse.plugin.editor.EditorPackage
25 public class EditorSwitch<T> extends Switch<T>
28 * The cached model package
29 * <!-- begin-user-doc -->
30 * <!-- end-user-doc -->
33 protected static EditorPackage modelPackage;
36 * Creates an instance of the switch.
37 * <!-- begin-user-doc -->
38 * <!-- end-user-doc -->
43 if (modelPackage == null)
45 modelPackage = EditorPackage.eINSTANCE;
50 * Checks whether this is a switch for the given package.
51 * <!-- begin-user-doc -->
52 * <!-- end-user-doc -->
53 * @param ePackage the package in question.
54 * @return whether this is a switch for the given package.
58 protected boolean isSwitchFor(EPackage ePackage)
60 return ePackage == modelPackage;
64 * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
65 * <!-- begin-user-doc -->
66 * <!-- end-user-doc -->
67 * @return the first non-null result returned by a <code>caseXXX</code> call.
71 protected T doSwitch(int classifierID, EObject theEObject)
75 case EditorPackage.MODEL:
77 Model model = (Model)theEObject;
78 T result = caseModel(model);
79 if (result == null) result = defaultCase(theEObject);
82 case EditorPackage.SENTENCE:
84 Sentence sentence = (Sentence)theEObject;
85 T result = caseSentence(sentence);
86 if (result == null) result = defaultCase(theEObject);
89 case EditorPackage.NODE:
91 Node node = (Node)theEObject;
92 T result = caseNode(node);
93 if (result == null) result = caseSentence(node);
94 if (result == null) result = defaultCase(theEObject);
97 case EditorPackage.NODE_MODEL:
99 NodeModel nodeModel = (NodeModel)theEObject;
100 T result = caseNodeModel(nodeModel);
101 if (result == null) result = defaultCase(theEObject);
104 case EditorPackage.NODE_OPERATING:
106 NodeOperating nodeOperating = (NodeOperating)theEObject;
107 T result = caseNodeOperating(nodeOperating);
108 if (result == null) result = caseSentence(nodeOperating);
109 if (result == null) result = defaultCase(theEObject);
112 case EditorPackage.CONNECTION:
114 Connection connection = (Connection)theEObject;
115 T result = caseConnection(connection);
116 if (result == null) result = caseSentence(connection);
117 if (result == null) result = defaultCase(theEObject);
120 case EditorPackage.CONNECTION_UPDATE:
122 ConnectionUpdate connectionUpdate = (ConnectionUpdate)theEObject;
123 T result = caseConnectionUpdate(connectionUpdate);
124 if (result == null) result = caseSentence(connectionUpdate);
125 if (result == null) result = defaultCase(theEObject);
128 case EditorPackage.FLOW:
130 Flow flow = (Flow)theEObject;
131 T result = caseFlow(flow);
132 if (result == null) result = caseSentence(flow);
133 if (result == null) result = defaultCase(theEObject);
136 case EditorPackage.FLOW_UPDATE:
138 FlowUpdate flowUpdate = (FlowUpdate)theEObject;
139 T result = caseFlowUpdate(flowUpdate);
140 if (result == null) result = caseSentence(flowUpdate);
141 if (result == null) result = defaultCase(theEObject);
144 case EditorPackage.OPERATION:
146 Operation operation = (Operation)theEObject;
147 T result = caseOperation(operation);
148 if (result == null) result = caseSentence(operation);
149 if (result == null) result = defaultCase(theEObject);
152 default: return defaultCase(theEObject);
157 * Returns the result of interpreting the object as an instance of '<em>Model</em>'.
158 * <!-- begin-user-doc -->
159 * This implementation returns null;
160 * returning a non-null result will terminate the switch.
161 * <!-- end-user-doc -->
162 * @param object the target of the switch.
163 * @return the result of interpreting the object as an instance of '<em>Model</em>'.
164 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
167 public T caseModel(Model object)
173 * Returns the result of interpreting the object as an instance of '<em>Sentence</em>'.
174 * <!-- begin-user-doc -->
175 * This implementation returns null;
176 * returning a non-null result will terminate the switch.
177 * <!-- end-user-doc -->
178 * @param object the target of the switch.
179 * @return the result of interpreting the object as an instance of '<em>Sentence</em>'.
180 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
183 public T caseSentence(Sentence object)
189 * Returns the result of interpreting the object as an instance of '<em>Node</em>'.
190 * <!-- begin-user-doc -->
191 * This implementation returns null;
192 * returning a non-null result will terminate the switch.
193 * <!-- end-user-doc -->
194 * @param object the target of the switch.
195 * @return the result of interpreting the object as an instance of '<em>Node</em>'.
196 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
199 public T caseNode(Node object)
205 * Returns the result of interpreting the object as an instance of '<em>Node Model</em>'.
206 * <!-- begin-user-doc -->
207 * This implementation returns null;
208 * returning a non-null result will terminate the switch.
209 * <!-- end-user-doc -->
210 * @param object the target of the switch.
211 * @return the result of interpreting the object as an instance of '<em>Node Model</em>'.
212 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
215 public T caseNodeModel(NodeModel object)
221 * Returns the result of interpreting the object as an instance of '<em>Node Operating</em>'.
222 * <!-- begin-user-doc -->
223 * This implementation returns null;
224 * returning a non-null result will terminate the switch.
225 * <!-- end-user-doc -->
226 * @param object the target of the switch.
227 * @return the result of interpreting the object as an instance of '<em>Node Operating</em>'.
228 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
231 public T caseNodeOperating(NodeOperating object)
237 * Returns the result of interpreting the object as an instance of '<em>Connection</em>'.
238 * <!-- begin-user-doc -->
239 * This implementation returns null;
240 * returning a non-null result will terminate the switch.
241 * <!-- end-user-doc -->
242 * @param object the target of the switch.
243 * @return the result of interpreting the object as an instance of '<em>Connection</em>'.
244 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
247 public T caseConnection(Connection object)
253 * Returns the result of interpreting the object as an instance of '<em>Connection Update</em>'.
254 * <!-- begin-user-doc -->
255 * This implementation returns null;
256 * returning a non-null result will terminate the switch.
257 * <!-- end-user-doc -->
258 * @param object the target of the switch.
259 * @return the result of interpreting the object as an instance of '<em>Connection Update</em>'.
260 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
263 public T caseConnectionUpdate(ConnectionUpdate object)
269 * Returns the result of interpreting the object as an instance of '<em>Flow</em>'.
270 * <!-- begin-user-doc -->
271 * This implementation returns null;
272 * returning a non-null result will terminate the switch.
273 * <!-- end-user-doc -->
274 * @param object the target of the switch.
275 * @return the result of interpreting the object as an instance of '<em>Flow</em>'.
276 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
279 public T caseFlow(Flow object)
285 * Returns the result of interpreting the object as an instance of '<em>Flow Update</em>'.
286 * <!-- begin-user-doc -->
287 * This implementation returns null;
288 * returning a non-null result will terminate the switch.
289 * <!-- end-user-doc -->
290 * @param object the target of the switch.
291 * @return the result of interpreting the object as an instance of '<em>Flow Update</em>'.
292 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
295 public T caseFlowUpdate(FlowUpdate object)
301 * Returns the result of interpreting the object as an instance of '<em>Operation</em>'.
302 * <!-- begin-user-doc -->
303 * This implementation returns null;
304 * returning a non-null result will terminate the switch.
305 * <!-- end-user-doc -->
306 * @param object the target of the switch.
307 * @return the result of interpreting the object as an instance of '<em>Operation</em>'.
308 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
311 public T caseOperation(Operation object)
317 * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
318 * <!-- begin-user-doc -->
319 * This implementation returns null;
320 * returning a non-null result will terminate the switch, but this is the last case anyway.
321 * <!-- end-user-doc -->
322 * @param object the target of the switch.
323 * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
324 * @see #doSwitch(org.eclipse.emf.ecore.EObject)
328 public T defaultCase(EObject object)