View Javadoc

1   /**
2    * (c) Mod4j and contributors
3    *
4    * $Id$
5    */
6   package org.mod4j.crossx.mm.crossx.util;
7   
8   import java.util.List;
9   
10  import org.eclipse.emf.ecore.EClass;
11  import org.eclipse.emf.ecore.EObject;
12  
13  import org.mod4j.crossx.mm.crossx.*;
14  
15  /**
16   * <!-- begin-user-doc -->
17   * The <b>Switch</b> for the model's inheritance hierarchy.
18   * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
19   * to invoke the <code>caseXXX</code> method for each class of the model,
20   * starting with the actual class of the object
21   * and proceeding up the inheritance hierarchy
22   * until a non-null result is returned,
23   * which is the result of the switch.
24   * <!-- end-user-doc -->
25   * @see org.mod4j.crossx.mm.crossx.CrossxPackage
26   * @generated
27   */
28  public class CrossxSwitch<T> {
29      /**
30       * The cached model package
31       * <!-- begin-user-doc -->
32       * <!-- end-user-doc -->
33       * @generated
34       */
35      protected static CrossxPackage modelPackage;
36  
37      /**
38       * Creates an instance of the switch.
39       * <!-- begin-user-doc -->
40       * <!-- end-user-doc -->
41       * @generated
42       */
43      public CrossxSwitch() {
44          if (modelPackage == null) {
45              modelPackage = CrossxPackage.eINSTANCE;
46          }
47      }
48  
49      /**
50       * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
51       * <!-- begin-user-doc -->
52       * <!-- end-user-doc -->
53       * @return the first non-null result returned by a <code>caseXXX</code> call.
54       * @generated
55       */
56      public T doSwitch(EObject theEObject) {
57          return doSwitch(theEObject.eClass(), theEObject);
58      }
59  
60      /**
61       * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
62       * <!-- begin-user-doc -->
63       * <!-- end-user-doc -->
64       * @return the first non-null result returned by a <code>caseXXX</code> call.
65       * @generated
66       */
67      protected T doSwitch(EClass theEClass, EObject theEObject) {
68          if (theEClass.eContainer() == modelPackage) {
69              return doSwitch(theEClass.getClassifierID(), theEObject);
70          }
71          else {
72              List<EClass> eSuperTypes = theEClass.getESuperTypes();
73              return
74                  eSuperTypes.isEmpty() ?
75                      defaultCase(theEObject) :
76                      doSwitch(eSuperTypes.get(0), theEObject);
77          }
78      }
79  
80      /**
81       * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
82       * <!-- begin-user-doc -->
83       * <!-- end-user-doc -->
84       * @return the first non-null result returned by a <code>caseXXX</code> call.
85       * @generated
86       */
87      protected T doSwitch(int classifierID, EObject theEObject) {
88          switch (classifierID) {
89              case CrossxPackage.MODEL_INFO: {
90                  ModelInfo modelInfo = (ModelInfo)theEObject;
91                  T result = caseModelInfo(modelInfo);
92                  if (result == null) result = defaultCase(theEObject);
93                  return result;
94              }
95              case CrossxPackage.SYMBOL: {
96                  Symbol symbol = (Symbol)theEObject;
97                  T result = caseSymbol(symbol);
98                  if (result == null) result = defaultCase(theEObject);
99                  return result;
100             }
101             case CrossxPackage.SYMBOL_PROPERTY: {
102                 SymbolProperty symbolProperty = (SymbolProperty)theEObject;
103                 T result = caseSymbolProperty(symbolProperty);
104                 if (result == null) result = defaultCase(theEObject);
105                 return result;
106             }
107             case CrossxPackage.LITERAL_SYMBOL_PROPERTY: {
108                 LiteralSymbolProperty literalSymbolProperty = (LiteralSymbolProperty)theEObject;
109                 T result = caseLiteralSymbolProperty(literalSymbolProperty);
110                 if (result == null) result = caseSymbolProperty(literalSymbolProperty);
111                 if (result == null) result = defaultCase(theEObject);
112                 return result;
113             }
114             case CrossxPackage.REFERENCE_SYMBOL_PROPERTY: {
115                 ReferenceSymbolProperty referenceSymbolProperty = (ReferenceSymbolProperty)theEObject;
116                 T result = caseReferenceSymbolProperty(referenceSymbolProperty);
117                 if (result == null) result = caseSymbolProperty(referenceSymbolProperty);
118                 if (result == null) result = defaultCase(theEObject);
119                 return result;
120             }
121             default: return defaultCase(theEObject);
122         }
123     }
124 
125     /**
126      * Returns the result of interpreting the object as an instance of '<em>Model Info</em>'.
127      * <!-- begin-user-doc -->
128      * This implementation returns null;
129      * returning a non-null result will terminate the switch.
130      * <!-- end-user-doc -->
131      * @param object the target of the switch.
132      * @return the result of interpreting the object as an instance of '<em>Model Info</em>'.
133      * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
134      * @generated
135      */
136     public T caseModelInfo(ModelInfo object) {
137         return null;
138     }
139 
140     /**
141      * Returns the result of interpreting the object as an instance of '<em>Symbol</em>'.
142      * <!-- begin-user-doc -->
143      * This implementation returns null;
144      * returning a non-null result will terminate the switch.
145      * <!-- end-user-doc -->
146      * @param object the target of the switch.
147      * @return the result of interpreting the object as an instance of '<em>Symbol</em>'.
148      * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
149      * @generated
150      */
151     public T caseSymbol(Symbol object) {
152         return null;
153     }
154 
155     /**
156      * Returns the result of interpreting the object as an instance of '<em>Symbol Property</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 interpreting the object as an instance of '<em>Symbol Property</em>'.
163      * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
164      * @generated
165      */
166     public T caseSymbolProperty(SymbolProperty object) {
167         return null;
168     }
169 
170     /**
171      * Returns the result of interpreting the object as an instance of '<em>Literal Symbol Property</em>'.
172      * <!-- begin-user-doc -->
173      * This implementation returns null;
174      * returning a non-null result will terminate the switch.
175      * <!-- end-user-doc -->
176      * @param object the target of the switch.
177      * @return the result of interpreting the object as an instance of '<em>Literal Symbol Property</em>'.
178      * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
179      * @generated
180      */
181     public T caseLiteralSymbolProperty(LiteralSymbolProperty object) {
182         return null;
183     }
184 
185     /**
186      * Returns the result of interpreting the object as an instance of '<em>Reference Symbol Property</em>'.
187      * <!-- begin-user-doc -->
188      * This implementation returns null;
189      * returning a non-null result will terminate the switch.
190      * <!-- end-user-doc -->
191      * @param object the target of the switch.
192      * @return the result of interpreting the object as an instance of '<em>Reference Symbol Property</em>'.
193      * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
194      * @generated
195      */
196     public T caseReferenceSymbolProperty(ReferenceSymbolProperty object) {
197         return null;
198     }
199 
200     /**
201      * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
202      * <!-- begin-user-doc -->
203      * This implementation returns null;
204      * returning a non-null result will terminate the switch, but this is the last case anyway.
205      * <!-- end-user-doc -->
206      * @param object the target of the switch.
207      * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
208      * @see #doSwitch(org.eclipse.emf.ecore.EObject)
209      * @generated
210      */
211     public T defaultCase(EObject object) {
212         return null;
213     }
214 
215 } //CrossxSwitch