KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > emf > ecore > change > util > ChangeSwitch


1 /**
2  * <copyright>
3  *
4  * Copyright (c) 2003-2004 IBM Corporation and others.
5  * All rights reserved. This program and the accompanying materials
6  * are made available under the terms of the Eclipse Public License v1.0
7  * which accompanies this distribution, and is available at
8  * http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Contributors:
11  * IBM - Initial API and implementation
12  *
13  * </copyright>
14  *
15  * $Id: ChangeSwitch.java,v 1.6 2005/06/08 06:16:16 nickb Exp $
16  */

17 package org.eclipse.emf.ecore.change.util;
18
19 import java.util.List JavaDoc;
20 import java.util.Map JavaDoc;
21
22 import org.eclipse.emf.ecore.EClass;
23 import org.eclipse.emf.ecore.EObject;
24 import org.eclipse.emf.ecore.change.*;
25
26
27 /**
28  * <!-- begin-user-doc -->
29  * The <b>Switch</b> for the model's inheritance hierarchy.
30  * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
31  * to invoke the <code>caseXXX</code> method for each class of the model,
32  * starting with the actual class of the object
33  * and proceeding up the inheritance hierarchy
34  * until a non-null result is returned,
35  * which is the result of the switch.
36  * <!-- end-user-doc -->
37  * @see org.eclipse.emf.ecore.change.ChangePackage
38  * @generated
39  */

40 public class ChangeSwitch {
41   /**
42    * The cached model package
43    * <!-- begin-user-doc -->
44    * <!-- end-user-doc -->
45    * @generated
46    */

47   protected static ChangePackage modelPackage;
48
49   /**
50    * Creates an instance of the switch.
51    * <!-- begin-user-doc -->
52    * <!-- end-user-doc -->
53    * @generated
54    */

55   public ChangeSwitch()
56   {
57     if (modelPackage == null)
58     {
59       modelPackage = ChangePackage.eINSTANCE;
60     }
61   }
62
63   /**
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.
68    * @generated
69    */

70   public Object JavaDoc doSwitch(EObject theEObject)
71   {
72     return doSwitch(theEObject.eClass(), theEObject);
73   }
74
75   /**
76    * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
77    * <!-- begin-user-doc -->
78    * <!-- end-user-doc -->
79    * @return the first non-null result returned by a <code>caseXXX</code> call.
80    * @generated
81    */

82   protected Object JavaDoc doSwitch(EClass theEClass, EObject theEObject)
83   {
84     if (theEClass.eContainer() == modelPackage)
85     {
86       return doSwitch(theEClass.getClassifierID(), theEObject);
87     }
88     else
89     {
90       List JavaDoc eSuperTypes = theEClass.getESuperTypes();
91       return
92         eSuperTypes.isEmpty() ?
93           defaultCase(theEObject) :
94           doSwitch((EClass)eSuperTypes.get(0), theEObject);
95     }
96   }
97
98   /**
99    * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
100    * <!-- begin-user-doc -->
101    * <!-- end-user-doc -->
102    * @return the first non-null result returned by a <code>caseXXX</code> call.
103    * @generated
104    */

105   protected Object JavaDoc doSwitch(int classifierID, EObject theEObject)
106   {
107     switch (classifierID)
108     {
109       case ChangePackage.CHANGE_DESCRIPTION:
110       {
111         ChangeDescription changeDescription = (ChangeDescription)theEObject;
112         Object JavaDoc result = caseChangeDescription(changeDescription);
113         if (result == null) result = defaultCase(theEObject);
114         return result;
115       }
116       case ChangePackage.EOBJECT_TO_CHANGES_MAP_ENTRY:
117       {
118         Map.Entry JavaDoc eObjectToChangesMapEntry = (Map.Entry JavaDoc)theEObject;
119         Object JavaDoc result = caseEObjectToChangesMapEntry(eObjectToChangesMapEntry);
120         if (result == null) result = defaultCase(theEObject);
121         return result;
122       }
123       case ChangePackage.FEATURE_CHANGE:
124       {
125         FeatureChange featureChange = (FeatureChange)theEObject;
126         Object JavaDoc result = caseFeatureChange(featureChange);
127         if (result == null) result = defaultCase(theEObject);
128         return result;
129       }
130       case ChangePackage.LIST_CHANGE:
131       {
132         ListChange listChange = (ListChange)theEObject;
133         Object JavaDoc result = caseListChange(listChange);
134         if (result == null) result = defaultCase(theEObject);
135         return result;
136       }
137       case ChangePackage.RESOURCE_CHANGE:
138       {
139         ResourceChange resourceChange = (ResourceChange)theEObject;
140         Object JavaDoc result = caseResourceChange(resourceChange);
141         if (result == null) result = defaultCase(theEObject);
142         return result;
143       }
144       case ChangePackage.FEATURE_MAP_ENTRY:
145       {
146         FeatureMapEntry featureMapEntry = (FeatureMapEntry)theEObject;
147         Object JavaDoc result = caseFeatureMapEntry(featureMapEntry);
148         if (result == null) result = defaultCase(theEObject);
149         return result;
150       }
151       default: return defaultCase(theEObject);
152     }
153   }
154
155   /**
156    * Returns the result of interpretting the object as an instance of '<em>Description</em>'.
157    * <!-- begin-user-doc -->
158    * This implementation returns null;
159    * returning a non-null result will terminate the switch.
160    * <!-- end-user-doc -->
161    * @param object the target of the switch.
162    * @return the result of interpretting the object as an instance of '<em>Description</em>'.
163    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
164    * @generated
165    */

166   public Object JavaDoc caseChangeDescription(ChangeDescription object)
167   {
168     return null;
169   }
170
171   /**
172    * Returns the result of interpretting the object as an instance of '<em>EObject To Changes Map Entry</em>'.
173    * <!-- begin-user-doc -->
174    * This implementation returns null;
175    * returning a non-null result will terminate the switch.
176    * <!-- end-user-doc -->
177    * @param object the target of the switch.
178    * @return the result of interpretting the object as an instance of '<em>EObject To Changes Map Entry</em>'.
179    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
180    * @generated
181    */

182   public Object JavaDoc caseEObjectToChangesMapEntry(Map.Entry JavaDoc object)
183   {
184     return null;
185   }
186
187   /**
188    * Returns the result of interpretting the object as an instance of '<em>Feature Change</em>'.
189    * <!-- begin-user-doc -->
190    * This implementation returns null;
191    * returning a non-null result will terminate the switch.
192    * <!-- end-user-doc -->
193    * @param object the target of the switch.
194    * @return the result of interpretting the object as an instance of '<em>Feature Change</em>'.
195    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
196    * @generated
197    */

198   public Object JavaDoc caseFeatureChange(FeatureChange object)
199   {
200     return null;
201   }
202
203   /**
204    * Returns the result of interpretting the object as an instance of '<em>List Change</em>'.
205    * <!-- begin-user-doc -->
206    * This implementation returns null;
207    * returning a non-null result will terminate the switch.
208    * <!-- end-user-doc -->
209    * @param object the target of the switch.
210    * @return the result of interpretting the object as an instance of '<em>List Change</em>'.
211    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
212    * @generated
213    */

214   public Object JavaDoc caseListChange(ListChange object)
215   {
216     return null;
217   }
218
219   /**
220    * Returns the result of interpretting the object as an instance of '<em>Resource Change</em>'.
221    * <!-- begin-user-doc -->
222    * This implementation returns null;
223    * returning a non-null result will terminate the switch.
224    * <!-- end-user-doc -->
225    * @param object the target of the switch.
226    * @return the result of interpretting the object as an instance of '<em>Resource Change</em>'.
227    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
228    * @generated
229    */

230   public Object JavaDoc caseResourceChange(ResourceChange object)
231   {
232     return null;
233   }
234
235   /**
236    * Returns the result of interpretting the object as an instance of '<em>Feature Map Entry</em>'.
237    * <!-- begin-user-doc -->
238    * This implementation returns null;
239    * returning a non-null result will terminate the switch.
240    * <!-- end-user-doc -->
241    * @param object the target of the switch.
242    * @return the result of interpretting the object as an instance of '<em>Feature Map Entry</em>'.
243    * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
244    * @generated
245    */

246   public Object JavaDoc caseFeatureMapEntry(FeatureMapEntry object)
247   {
248     return null;
249   }
250
251   /**
252    * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
253    * <!-- begin-user-doc -->
254    * This implementation returns null;
255    * returning a non-null result will terminate the switch, but this is the last case anyway.
256    * <!-- end-user-doc -->
257    * @param object the target of the switch.
258    * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
259    * @see #doSwitch(org.eclipse.emf.ecore.EObject)
260    * @generated
261    */

262   public Object JavaDoc defaultCase(EObject object)
263   {
264     return null;
265   }
266
267 } //ChangeSwitch
268
Popular Tags