001    /**
002     * <copyright>
003     * </copyright>
004     *
005     * $Id$
006     */
007    package com.hammurapi.config.util;
008    
009    import com.hammurapi.config.*;
010    
011    import com.hammurapi.party.CommonObject;
012    import java.util.List;
013    
014    import org.eclipse.emf.ecore.EClass;
015    import org.eclipse.emf.ecore.EObject;
016    
017    /**
018     * <!-- begin-user-doc -->
019     * The <b>Switch</b> for the model's inheritance hierarchy.
020     * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
021     * to invoke the <code>caseXXX</code> method for each class of the model,
022     * starting with the actual class of the object
023     * and proceeding up the inheritance hierarchy
024     * until a non-null result is returned,
025     * which is the result of the switch.
026     * <!-- end-user-doc -->
027     * @see com.hammurapi.config.ConfigPackage
028     * @generated
029     */
030    public class ConfigSwitch<T> {
031            /**
032             * The cached model package
033             * <!-- begin-user-doc -->
034             * <!-- end-user-doc -->
035             * @generated
036             */
037            protected static ConfigPackage modelPackage;
038    
039            /**
040             * Creates an instance of the switch.
041             * <!-- begin-user-doc -->
042             * <!-- end-user-doc -->
043             * @generated
044             */
045            public ConfigSwitch() {
046                    if (modelPackage == null) {
047                            modelPackage = ConfigPackage.eINSTANCE;
048                    }
049            }
050    
051            /**
052             * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
053             * <!-- begin-user-doc -->
054             * <!-- end-user-doc -->
055             * @return the first non-null result returned by a <code>caseXXX</code> call.
056             * @generated
057             */
058            public T doSwitch(EObject theEObject) {
059                    return doSwitch(theEObject.eClass(), theEObject);
060            }
061    
062            /**
063             * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
064             * <!-- begin-user-doc -->
065             * <!-- end-user-doc -->
066             * @return the first non-null result returned by a <code>caseXXX</code> call.
067             * @generated
068             */
069            protected T doSwitch(EClass theEClass, EObject theEObject) {
070                    if (theEClass.eContainer() == modelPackage) {
071                            return doSwitch(theEClass.getClassifierID(), theEObject);
072                    }
073                    else {
074                            List<EClass> eSuperTypes = theEClass.getESuperTypes();
075                            return
076                                    eSuperTypes.isEmpty() ?
077                                            defaultCase(theEObject) :
078                                            doSwitch(eSuperTypes.get(0), theEObject);
079                    }
080            }
081    
082            /**
083             * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
084             * <!-- begin-user-doc -->
085             * <!-- end-user-doc -->
086             * @return the first non-null result returned by a <code>caseXXX</code> call.
087             * @generated
088             */
089            protected T doSwitch(int classifierID, EObject theEObject) {
090                    switch (classifierID) {
091                            case ConfigPackage.PATH: {
092                                    Path path = (Path)theEObject;
093                                    T result = casePath(path);
094                                    if (result == null) result = defaultCase(theEObject);
095                                    return result;
096                            }
097                            case ConfigPackage.FACTORY: {
098                                    Factory factory = (Factory)theEObject;
099                                    T result = caseFactory(factory);
100                                    if (result == null) result = caseCommonObject(factory);
101                                    if (result == null) result = defaultCase(theEObject);
102                                    return result;
103                            }
104                            case ConfigPackage.PROFILE: {
105                                    Profile profile = (Profile)theEObject;
106                                    T result = caseProfile(profile);
107                                    if (result == null) result = casePropertySource(profile);
108                                    if (result == null) result = defaultCase(theEObject);
109                                    return result;
110                            }
111                            case ConfigPackage.OBJECT_DEFINITION: {
112                                    ObjectDefinition objectDefinition = (ObjectDefinition)theEObject;
113                                    T result = caseObjectDefinition(objectDefinition);
114                                    if (result == null) result = caseFactory(objectDefinition);
115                                    if (result == null) result = casePropertySource(objectDefinition);
116                                    if (result == null) result = caseCommonObject(objectDefinition);
117                                    if (result == null) result = defaultCase(theEObject);
118                                    return result;
119                            }
120                            case ConfigPackage.COLLECTION: {
121                                    Collection collection = (Collection)theEObject;
122                                    T result = caseCollection(collection);
123                                    if (result == null) result = caseFactory(collection);
124                                    if (result == null) result = caseCommonObject(collection);
125                                    if (result == null) result = defaultCase(theEObject);
126                                    return result;
127                            }
128                            case ConfigPackage.CONSTRUCTOR: {
129                                    Constructor constructor = (Constructor)theEObject;
130                                    T result = caseConstructor(constructor);
131                                    if (result == null) result = defaultCase(theEObject);
132                                    return result;
133                            }
134                            case ConfigPackage.MAP: {
135                                    Map map = (Map)theEObject;
136                                    T result = caseMap(map);
137                                    if (result == null) result = caseFactory(map);
138                                    if (result == null) result = caseCommonObject(map);
139                                    if (result == null) result = defaultCase(theEObject);
140                                    return result;
141                            }
142                            case ConfigPackage.MAP_ENTRY: {
143                                    MapEntry mapEntry = (MapEntry)theEObject;
144                                    T result = caseMapEntry(mapEntry);
145                                    if (result == null) result = defaultCase(theEObject);
146                                    return result;
147                            }
148                            case ConfigPackage.REFERENCE: {
149                                    Reference reference = (Reference)theEObject;
150                                    T result = caseReference(reference);
151                                    if (result == null) result = caseFactory(reference);
152                                    if (result == null) result = caseCommonObject(reference);
153                                    if (result == null) result = defaultCase(theEObject);
154                                    return result;
155                            }
156                            case ConfigPackage.PROPERTY_SOURCE: {
157                                    PropertySource propertySource = (PropertySource)theEObject;
158                                    T result = casePropertySource(propertySource);
159                                    if (result == null) result = defaultCase(theEObject);
160                                    return result;
161                            }
162                            case ConfigPackage.NULL: {
163                                    Null null_ = (Null)theEObject;
164                                    T result = caseNull(null_);
165                                    if (result == null) result = caseFactory(null_);
166                                    if (result == null) result = caseCommonObject(null_);
167                                    if (result == null) result = defaultCase(theEObject);
168                                    return result;
169                            }
170                            case ConfigPackage.SCRIPT: {
171                                    Script script = (Script)theEObject;
172                                    T result = caseScript(script);
173                                    if (result == null) result = caseFactory(script);
174                                    if (result == null) result = casePropertySource(script);
175                                    if (result == null) result = caseCommonObject(script);
176                                    if (result == null) result = defaultCase(theEObject);
177                                    return result;
178                            }
179                            case ConfigPackage.NAMED_REFERENCE: {
180                                    NamedReference namedReference = (NamedReference)theEObject;
181                                    T result = caseNamedReference(namedReference);
182                                    if (result == null) result = caseNamed(namedReference);
183                                    if (result == null) result = caseReference(namedReference);
184                                    if (result == null) result = caseFactory(namedReference);
185                                    if (result == null) result = caseCommonObject(namedReference);
186                                    if (result == null) result = defaultCase(theEObject);
187                                    return result;
188                            }
189                            case ConfigPackage.NAMED_OBJECT_DEFINITION: {
190                                    NamedObjectDefinition namedObjectDefinition = (NamedObjectDefinition)theEObject;
191                                    T result = caseNamedObjectDefinition(namedObjectDefinition);
192                                    if (result == null) result = caseNamed(namedObjectDefinition);
193                                    if (result == null) result = caseObjectDefinition(namedObjectDefinition);
194                                    if (result == null) result = caseFactory(namedObjectDefinition);
195                                    if (result == null) result = casePropertySource(namedObjectDefinition);
196                                    if (result == null) result = caseCommonObject(namedObjectDefinition);
197                                    if (result == null) result = defaultCase(theEObject);
198                                    return result;
199                            }
200                            case ConfigPackage.NAMED_COLLECTION: {
201                                    NamedCollection namedCollection = (NamedCollection)theEObject;
202                                    T result = caseNamedCollection(namedCollection);
203                                    if (result == null) result = caseNamed(namedCollection);
204                                    if (result == null) result = caseCollection(namedCollection);
205                                    if (result == null) result = caseFactory(namedCollection);
206                                    if (result == null) result = caseCommonObject(namedCollection);
207                                    if (result == null) result = defaultCase(theEObject);
208                                    return result;
209                            }
210                            case ConfigPackage.NAMED_MAP: {
211                                    NamedMap namedMap = (NamedMap)theEObject;
212                                    T result = caseNamedMap(namedMap);
213                                    if (result == null) result = caseNamed(namedMap);
214                                    if (result == null) result = caseMap(namedMap);
215                                    if (result == null) result = caseFactory(namedMap);
216                                    if (result == null) result = caseCommonObject(namedMap);
217                                    if (result == null) result = defaultCase(theEObject);
218                                    return result;
219                            }
220                            case ConfigPackage.NAMED: {
221                                    Named named = (Named)theEObject;
222                                    T result = caseNamed(named);
223                                    if (result == null) result = caseFactory(named);
224                                    if (result == null) result = caseCommonObject(named);
225                                    if (result == null) result = defaultCase(theEObject);
226                                    return result;
227                            }
228                            case ConfigPackage.METHOD_CALL: {
229                                    MethodCall methodCall = (MethodCall)theEObject;
230                                    T result = caseMethodCall(methodCall);
231                                    if (result == null) result = caseNamed(methodCall);
232                                    if (result == null) result = casePropertySource(methodCall);
233                                    if (result == null) result = caseFactory(methodCall);
234                                    if (result == null) result = caseCommonObject(methodCall);
235                                    if (result == null) result = defaultCase(theEObject);
236                                    return result;
237                            }
238                            case ConfigPackage.NAMED_SCRIPT: {
239                                    NamedScript namedScript = (NamedScript)theEObject;
240                                    T result = caseNamedScript(namedScript);
241                                    if (result == null) result = caseNamed(namedScript);
242                                    if (result == null) result = caseScript(namedScript);
243                                    if (result == null) result = caseFactory(namedScript);
244                                    if (result == null) result = casePropertySource(namedScript);
245                                    if (result == null) result = caseCommonObject(namedScript);
246                                    if (result == null) result = defaultCase(theEObject);
247                                    return result;
248                            }
249                            case ConfigPackage.SOURCE: {
250                                    Source source = (Source)theEObject;
251                                    T result = caseSource(source);
252                                    if (result == null) result = defaultCase(theEObject);
253                                    return result;
254                            }
255                            default: return defaultCase(theEObject);
256                    }
257            }
258    
259            /**
260             * Returns the result of interpreting the object as an instance of '<em>Path</em>'.
261             * <!-- begin-user-doc -->
262             * This implementation returns null;
263             * returning a non-null result will terminate the switch.
264             * <!-- end-user-doc -->
265             * @param object the target of the switch.
266             * @return the result of interpreting the object as an instance of '<em>Path</em>'.
267             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
268             * @generated
269             */
270            public T casePath(Path object) {
271                    return null;
272            }
273    
274            /**
275             * Returns the result of interpreting the object as an instance of '<em>Factory</em>'.
276             * <!-- begin-user-doc -->
277             * This implementation returns null;
278             * returning a non-null result will terminate the switch.
279             * <!-- end-user-doc -->
280             * @param object the target of the switch.
281             * @return the result of interpreting the object as an instance of '<em>Factory</em>'.
282             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
283             * @generated
284             */
285            public T caseFactory(Factory object) {
286                    return null;
287            }
288    
289            /**
290             * Returns the result of interpreting the object as an instance of '<em>Profile</em>'.
291             * <!-- begin-user-doc -->
292             * This implementation returns null;
293             * returning a non-null result will terminate the switch.
294             * <!-- end-user-doc -->
295             * @param object the target of the switch.
296             * @return the result of interpreting the object as an instance of '<em>Profile</em>'.
297             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
298             * @generated
299             */
300            public T caseProfile(Profile object) {
301                    return null;
302            }
303    
304            /**
305             * Returns the result of interpreting the object as an instance of '<em>Object Definition</em>'.
306             * <!-- begin-user-doc -->
307             * This implementation returns null;
308             * returning a non-null result will terminate the switch.
309             * <!-- end-user-doc -->
310             * @param object the target of the switch.
311             * @return the result of interpreting the object as an instance of '<em>Object Definition</em>'.
312             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
313             * @generated
314             */
315            public T caseObjectDefinition(ObjectDefinition object) {
316                    return null;
317            }
318    
319            /**
320             * Returns the result of interpreting the object as an instance of '<em>Collection</em>'.
321             * <!-- begin-user-doc -->
322             * This implementation returns null;
323             * returning a non-null result will terminate the switch.
324             * <!-- end-user-doc -->
325             * @param object the target of the switch.
326             * @return the result of interpreting the object as an instance of '<em>Collection</em>'.
327             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
328             * @generated
329             */
330            public T caseCollection(Collection object) {
331                    return null;
332            }
333    
334            /**
335             * Returns the result of interpreting the object as an instance of '<em>Constructor</em>'.
336             * <!-- begin-user-doc -->
337             * This implementation returns null;
338             * returning a non-null result will terminate the switch.
339             * <!-- end-user-doc -->
340             * @param object the target of the switch.
341             * @return the result of interpreting the object as an instance of '<em>Constructor</em>'.
342             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
343             * @generated
344             */
345            public T caseConstructor(Constructor object) {
346                    return null;
347            }
348    
349            /**
350             * Returns the result of interpreting the object as an instance of '<em>Map</em>'.
351             * <!-- begin-user-doc -->
352             * This implementation returns null;
353             * returning a non-null result will terminate the switch.
354             * <!-- end-user-doc -->
355             * @param object the target of the switch.
356             * @return the result of interpreting the object as an instance of '<em>Map</em>'.
357             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
358             * @generated
359             */
360            public T caseMap(Map object) {
361                    return null;
362            }
363    
364            /**
365             * Returns the result of interpreting the object as an instance of '<em>Map Entry</em>'.
366             * <!-- begin-user-doc -->
367             * This implementation returns null;
368             * returning a non-null result will terminate the switch.
369             * <!-- end-user-doc -->
370             * @param object the target of the switch.
371             * @return the result of interpreting the object as an instance of '<em>Map Entry</em>'.
372             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
373             * @generated
374             */
375            public T caseMapEntry(MapEntry object) {
376                    return null;
377            }
378    
379            /**
380             * Returns the result of interpreting the object as an instance of '<em>Reference</em>'.
381             * <!-- begin-user-doc -->
382             * This implementation returns null;
383             * returning a non-null result will terminate the switch.
384             * <!-- end-user-doc -->
385             * @param object the target of the switch.
386             * @return the result of interpreting the object as an instance of '<em>Reference</em>'.
387             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
388             * @generated
389             */
390            public T caseReference(Reference object) {
391                    return null;
392            }
393    
394            /**
395             * Returns the result of interpreting the object as an instance of '<em>Property Source</em>'.
396             * <!-- begin-user-doc -->
397             * This implementation returns null;
398             * returning a non-null result will terminate the switch.
399             * <!-- end-user-doc -->
400             * @param object the target of the switch.
401             * @return the result of interpreting the object as an instance of '<em>Property Source</em>'.
402             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
403             * @generated
404             */
405            public T casePropertySource(PropertySource object) {
406                    return null;
407            }
408    
409            /**
410             * Returns the result of interpreting the object as an instance of '<em>Null</em>'.
411             * <!-- begin-user-doc -->
412             * This implementation returns null;
413             * returning a non-null result will terminate the switch.
414             * <!-- end-user-doc -->
415             * @param object the target of the switch.
416             * @return the result of interpreting the object as an instance of '<em>Null</em>'.
417             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
418             * @generated
419             */
420            public T caseNull(Null object) {
421                    return null;
422            }
423    
424            /**
425             * Returns the result of interpreting the object as an instance of '<em>Script</em>'.
426             * <!-- begin-user-doc -->
427             * This implementation returns null;
428             * returning a non-null result will terminate the switch.
429             * <!-- end-user-doc -->
430             * @param object the target of the switch.
431             * @return the result of interpreting the object as an instance of '<em>Script</em>'.
432             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
433             * @generated
434             */
435            public T caseScript(Script object) {
436                    return null;
437            }
438    
439            /**
440             * Returns the result of interpreting the object as an instance of '<em>Named Reference</em>'.
441             * <!-- begin-user-doc -->
442             * This implementation returns null;
443             * returning a non-null result will terminate the switch.
444             * <!-- end-user-doc -->
445             * @param object the target of the switch.
446             * @return the result of interpreting the object as an instance of '<em>Named Reference</em>'.
447             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
448             * @generated
449             */
450            public T caseNamedReference(NamedReference object) {
451                    return null;
452            }
453    
454            /**
455             * Returns the result of interpreting the object as an instance of '<em>Named Object Definition</em>'.
456             * <!-- begin-user-doc -->
457             * This implementation returns null;
458             * returning a non-null result will terminate the switch.
459             * <!-- end-user-doc -->
460             * @param object the target of the switch.
461             * @return the result of interpreting the object as an instance of '<em>Named Object Definition</em>'.
462             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
463             * @generated
464             */
465            public T caseNamedObjectDefinition(NamedObjectDefinition object) {
466                    return null;
467            }
468    
469            /**
470             * Returns the result of interpreting the object as an instance of '<em>Named Collection</em>'.
471             * <!-- begin-user-doc -->
472             * This implementation returns null;
473             * returning a non-null result will terminate the switch.
474             * <!-- end-user-doc -->
475             * @param object the target of the switch.
476             * @return the result of interpreting the object as an instance of '<em>Named Collection</em>'.
477             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
478             * @generated
479             */
480            public T caseNamedCollection(NamedCollection object) {
481                    return null;
482            }
483    
484            /**
485             * Returns the result of interpreting the object as an instance of '<em>Named Map</em>'.
486             * <!-- begin-user-doc -->
487             * This implementation returns null;
488             * returning a non-null result will terminate the switch.
489             * <!-- end-user-doc -->
490             * @param object the target of the switch.
491             * @return the result of interpreting the object as an instance of '<em>Named Map</em>'.
492             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
493             * @generated
494             */
495            public T caseNamedMap(NamedMap object) {
496                    return null;
497            }
498    
499            /**
500             * Returns the result of interpreting the object as an instance of '<em>Named</em>'.
501             * <!-- begin-user-doc -->
502             * This implementation returns null;
503             * returning a non-null result will terminate the switch.
504             * <!-- end-user-doc -->
505             * @param object the target of the switch.
506             * @return the result of interpreting the object as an instance of '<em>Named</em>'.
507             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
508             * @generated
509             */
510            public T caseNamed(Named object) {
511                    return null;
512            }
513    
514            /**
515             * Returns the result of interpreting the object as an instance of '<em>Method Call</em>'.
516             * <!-- begin-user-doc -->
517             * This implementation returns null;
518             * returning a non-null result will terminate the switch.
519             * <!-- end-user-doc -->
520             * @param object the target of the switch.
521             * @return the result of interpreting the object as an instance of '<em>Method Call</em>'.
522             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
523             * @generated
524             */
525            public T caseMethodCall(MethodCall object) {
526                    return null;
527            }
528    
529            /**
530             * Returns the result of interpreting the object as an instance of '<em>Named Script</em>'.
531             * <!-- begin-user-doc -->
532             * This implementation returns null;
533             * returning a non-null result will terminate the switch.
534             * <!-- end-user-doc -->
535             * @param object the target of the switch.
536             * @return the result of interpreting the object as an instance of '<em>Named Script</em>'.
537             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
538             * @generated
539             */
540            public T caseNamedScript(NamedScript object) {
541                    return null;
542            }
543    
544            /**
545             * Returns the result of interpreting the object as an instance of '<em>Source</em>'.
546             * <!-- begin-user-doc -->
547             * This implementation returns null;
548             * returning a non-null result will terminate the switch.
549             * <!-- end-user-doc -->
550             * @param object the target of the switch.
551             * @return the result of interpreting the object as an instance of '<em>Source</em>'.
552             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
553             * @generated
554             */
555            public T caseSource(Source object) {
556                    return null;
557            }
558    
559            /**
560             * Returns the result of interpreting the object as an instance of '<em>Common Object</em>'.
561             * <!-- begin-user-doc -->
562             * This implementation returns null;
563             * returning a non-null result will terminate the switch.
564             * <!-- end-user-doc -->
565             * @param object the target of the switch.
566             * @return the result of interpreting the object as an instance of '<em>Common Object</em>'.
567             * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
568             * @generated
569             */
570            public T caseCommonObject(CommonObject object) {
571                    return null;
572            }
573    
574            /**
575             * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
576             * <!-- begin-user-doc -->
577             * This implementation returns null;
578             * returning a non-null result will terminate the switch, but this is the last case anyway.
579             * <!-- end-user-doc -->
580             * @param object the target of the switch.
581             * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
582             * @see #doSwitch(org.eclipse.emf.ecore.EObject)
583             * @generated
584             */
585            public T defaultCase(EObject object) {
586                    return null;
587            }
588    
589    } //ConfigSwitch