/** | |
* | |
* Copyright (c) 2009 Hatha Systems. | |
* 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: | |
* Nikolai Mansourov (Hatha Systems) - initial API and implementation | |
* Gabriel Barbier (Mia-Software) - minor evolutions for version 1.1 | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.modisco.omg.kdm.kdm.util; | |
import java.util.List; | |
import org.eclipse.emf.ecore.EClass; | |
import org.eclipse.emf.ecore.EObject; | |
import org.eclipse.modisco.omg.kdm.core.Element; | |
import org.eclipse.modisco.omg.kdm.core.ModelElement; | |
import org.eclipse.modisco.omg.kdm.kdm.Annotation; | |
import org.eclipse.modisco.omg.kdm.kdm.Attribute; | |
import org.eclipse.modisco.omg.kdm.kdm.Audit; | |
import org.eclipse.modisco.omg.kdm.kdm.ExtendedValue; | |
import org.eclipse.modisco.omg.kdm.kdm.ExtensionFamily; | |
import org.eclipse.modisco.omg.kdm.kdm.KDMFramework; | |
import org.eclipse.modisco.omg.kdm.kdm.KDMModel; | |
import org.eclipse.modisco.omg.kdm.kdm.KdmPackage; | |
import org.eclipse.modisco.omg.kdm.kdm.Segment; | |
import org.eclipse.modisco.omg.kdm.kdm.Stereotype; | |
import org.eclipse.modisco.omg.kdm.kdm.TagDefinition; | |
import org.eclipse.modisco.omg.kdm.kdm.TaggedRef; | |
import org.eclipse.modisco.omg.kdm.kdm.TaggedValue; | |
/** | |
* <!-- begin-user-doc --> | |
* The <b>Switch</b> for the model's inheritance hierarchy. | |
* It supports the call {@link #doSwitch(EObject) doSwitch(object)} | |
* to invoke the <code>caseXXX</code> method for each class of the model, | |
* starting with the actual class of the object | |
* and proceeding up the inheritance hierarchy | |
* until a non-null result is returned, | |
* which is the result of the switch. | |
* <!-- end-user-doc --> | |
* @see org.eclipse.modisco.omg.kdm.kdm.KdmPackage | |
* @generated | |
*/ | |
public class KdmSwitch<T> { | |
/** | |
* The cached model package | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected static KdmPackage modelPackage; | |
/** | |
* Creates an instance of the switch. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public KdmSwitch() { | |
if (modelPackage == null) { | |
modelPackage = KdmPackage.eINSTANCE; | |
} | |
} | |
/** | |
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @return the first non-null result returned by a <code>caseXXX</code> call. | |
* @generated | |
*/ | |
public T doSwitch(EObject theEObject) { | |
return doSwitch(theEObject.eClass(), theEObject); | |
} | |
/** | |
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @return the first non-null result returned by a <code>caseXXX</code> call. | |
* @generated | |
*/ | |
protected T doSwitch(EClass theEClass, EObject theEObject) { | |
if (theEClass.eContainer() == modelPackage) { | |
return doSwitch(theEClass.getClassifierID(), theEObject); | |
} | |
else { | |
List<EClass> eSuperTypes = theEClass.getESuperTypes(); | |
return | |
eSuperTypes.isEmpty() ? | |
defaultCase(theEObject) : | |
doSwitch(eSuperTypes.get(0), theEObject); | |
} | |
} | |
/** | |
* Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @return the first non-null result returned by a <code>caseXXX</code> call. | |
* @generated | |
*/ | |
protected T doSwitch(int classifierID, EObject theEObject) { | |
switch (classifierID) { | |
case KdmPackage.KDM_FRAMEWORK: { | |
KDMFramework kdmFramework = (KDMFramework)theEObject; | |
T result = caseKDMFramework(kdmFramework); | |
if (result == null) result = caseModelElement(kdmFramework); | |
if (result == null) result = caseElement(kdmFramework); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.KDM_MODEL: { | |
KDMModel kdmModel = (KDMModel)theEObject; | |
T result = caseKDMModel(kdmModel); | |
if (result == null) result = caseKDMFramework(kdmModel); | |
if (result == null) result = caseModelElement(kdmModel); | |
if (result == null) result = caseElement(kdmModel); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.SEGMENT: { | |
Segment segment = (Segment)theEObject; | |
T result = caseSegment(segment); | |
if (result == null) result = caseKDMFramework(segment); | |
if (result == null) result = caseModelElement(segment); | |
if (result == null) result = caseElement(segment); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.AUDIT: { | |
Audit audit = (Audit)theEObject; | |
T result = caseAudit(audit); | |
if (result == null) result = caseElement(audit); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.STEREOTYPE: { | |
Stereotype stereotype = (Stereotype)theEObject; | |
T result = caseStereotype(stereotype); | |
if (result == null) result = caseElement(stereotype); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.TAG_DEFINITION: { | |
TagDefinition tagDefinition = (TagDefinition)theEObject; | |
T result = caseTagDefinition(tagDefinition); | |
if (result == null) result = caseElement(tagDefinition); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.EXTENSION_FAMILY: { | |
ExtensionFamily extensionFamily = (ExtensionFamily)theEObject; | |
T result = caseExtensionFamily(extensionFamily); | |
if (result == null) result = caseElement(extensionFamily); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.EXTENDED_VALUE: { | |
ExtendedValue extendedValue = (ExtendedValue)theEObject; | |
T result = caseExtendedValue(extendedValue); | |
if (result == null) result = caseElement(extendedValue); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.TAGGED_VALUE: { | |
TaggedValue taggedValue = (TaggedValue)theEObject; | |
T result = caseTaggedValue(taggedValue); | |
if (result == null) result = caseExtendedValue(taggedValue); | |
if (result == null) result = caseElement(taggedValue); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.TAGGED_REF: { | |
TaggedRef taggedRef = (TaggedRef)theEObject; | |
T result = caseTaggedRef(taggedRef); | |
if (result == null) result = caseExtendedValue(taggedRef); | |
if (result == null) result = caseElement(taggedRef); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.ATTRIBUTE: { | |
Attribute attribute = (Attribute)theEObject; | |
T result = caseAttribute(attribute); | |
if (result == null) result = caseElement(attribute); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case KdmPackage.ANNOTATION: { | |
Annotation annotation = (Annotation)theEObject; | |
T result = caseAnnotation(annotation); | |
if (result == null) result = caseElement(annotation); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
default: return defaultCase(theEObject); | |
} | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>KDM Framework</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>KDM Framework</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseKDMFramework(KDMFramework object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>KDM Model</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>KDM Model</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseKDMModel(KDMModel object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Segment</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Segment</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseSegment(Segment object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Audit</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Audit</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseAudit(Audit object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Stereotype</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Stereotype</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseStereotype(Stereotype object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Tag Definition</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Tag Definition</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseTagDefinition(TagDefinition object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Extension Family</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Extension Family</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseExtensionFamily(ExtensionFamily object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Extended Value</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Extended Value</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseExtendedValue(ExtendedValue object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Tagged Value</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Tagged Value</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseTaggedValue(TaggedValue object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Tagged Ref</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Tagged Ref</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseTaggedRef(TaggedRef object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Attribute</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Attribute</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseAttribute(Attribute object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Annotation</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Annotation</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseAnnotation(Annotation object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Element</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Element</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseElement(Element object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Model Element</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>Model Element</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseModelElement(ModelElement object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EObject</em>'. | |
* <!-- begin-user-doc --> | |
* This implementation returns null; | |
* returning a non-null result will terminate the switch, but this is the last case anyway. | |
* <!-- end-user-doc --> | |
* @param object the target of the switch. | |
* @return the result of interpreting the object as an instance of '<em>EObject</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) | |
* @generated | |
*/ | |
public T defaultCase(EObject object) { | |
return null; | |
} | |
} //KdmSwitch |