/** * <copyright> * </copyright> * * $Id$ */ package orgomg.cwm.objectmodel.core.util; import java.util.List; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import orgomg.cwm.objectmodel.core.Attribute; import orgomg.cwm.objectmodel.core.BooleanExpression; import orgomg.cwm.objectmodel.core.Classifier; import orgomg.cwm.objectmodel.core.Constraint; import orgomg.cwm.objectmodel.core.CorePackage; import orgomg.cwm.objectmodel.core.DataType; import orgomg.cwm.objectmodel.core.Dependency; import orgomg.cwm.objectmodel.core.Element; import orgomg.cwm.objectmodel.core.Expression; import orgomg.cwm.objectmodel.core.Feature; import orgomg.cwm.objectmodel.core.Model; import orgomg.cwm.objectmodel.core.ModelElement; import orgomg.cwm.objectmodel.core.Multiplicity; import orgomg.cwm.objectmodel.core.MultiplicityRange; import orgomg.cwm.objectmodel.core.Namespace; import orgomg.cwm.objectmodel.core.ProcedureExpression; import orgomg.cwm.objectmodel.core.Stereotype; import orgomg.cwm.objectmodel.core.StructuralFeature; import orgomg.cwm.objectmodel.core.Subsystem; import orgomg.cwm.objectmodel.core.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 orgomg.cwm.objectmodel.core.CorePackage * @generated */ public class CoreSwitch<T> { /** * The cached model package * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected static CorePackage modelPackage; /** * Creates an instance of the switch. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public CoreSwitch() { if (modelPackage == null) { modelPackage = CorePackage.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 CorePackage.ELEMENT: { Element element = (Element)theEObject; T result = caseElement(element); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.MODEL_ELEMENT: { ModelElement modelElement = (ModelElement)theEObject; T result = caseModelElement(modelElement); if (result == null) result = caseElement(modelElement); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.NAMESPACE: { Namespace namespace = (Namespace)theEObject; T result = caseNamespace(namespace); if (result == null) result = caseModelElement(namespace); if (result == null) result = caseElement(namespace); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.CLASSIFIER: { Classifier classifier = (Classifier)theEObject; T result = caseClassifier(classifier); if (result == null) result = caseNamespace(classifier); if (result == null) result = caseModelElement(classifier); if (result == null) result = caseElement(classifier); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.CLASS: { orgomg.cwm.objectmodel.core.Class class_ = (orgomg.cwm.objectmodel.core.Class)theEObject; T result = caseClass(class_); if (result == null) result = caseClassifier(class_); if (result == null) result = caseNamespace(class_); if (result == null) result = caseModelElement(class_); if (result == null) result = caseElement(class_); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.DATA_TYPE: { DataType dataType = (DataType)theEObject; T result = caseDataType(dataType); if (result == null) result = caseClassifier(dataType); if (result == null) result = caseNamespace(dataType); if (result == null) result = caseModelElement(dataType); if (result == null) result = caseElement(dataType); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.PACKAGE: { orgomg.cwm.objectmodel.core.Package package_ = (orgomg.cwm.objectmodel.core.Package)theEObject; T result = casePackage(package_); if (result == null) result = caseNamespace(package_); if (result == null) result = caseModelElement(package_); if (result == null) result = caseElement(package_); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.SUBSYSTEM: { Subsystem subsystem = (Subsystem)theEObject; T result = caseSubsystem(subsystem); if (result == null) result = caseClassifier(subsystem); if (result == null) result = casePackage(subsystem); if (result == null) result = caseNamespace(subsystem); if (result == null) result = caseModelElement(subsystem); if (result == null) result = caseElement(subsystem); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.MODEL: { Model model = (Model)theEObject; T result = caseModel(model); if (result == null) result = casePackage(model); if (result == null) result = caseNamespace(model); if (result == null) result = caseModelElement(model); if (result == null) result = caseElement(model); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.FEATURE: { Feature feature = (Feature)theEObject; T result = caseFeature(feature); if (result == null) result = caseModelElement(feature); if (result == null) result = caseElement(feature); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.STRUCTURAL_FEATURE: { StructuralFeature structuralFeature = (StructuralFeature)theEObject; T result = caseStructuralFeature(structuralFeature); if (result == null) result = caseFeature(structuralFeature); if (result == null) result = caseModelElement(structuralFeature); if (result == null) result = caseElement(structuralFeature); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.ATTRIBUTE: { Attribute attribute = (Attribute)theEObject; T result = caseAttribute(attribute); if (result == null) result = caseStructuralFeature(attribute); if (result == null) result = caseFeature(attribute); if (result == null) result = caseModelElement(attribute); if (result == null) result = caseElement(attribute); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.CONSTRAINT: { Constraint constraint = (Constraint)theEObject; T result = caseConstraint(constraint); if (result == null) result = caseModelElement(constraint); if (result == null) result = caseElement(constraint); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.DEPENDENCY: { Dependency dependency = (Dependency)theEObject; T result = caseDependency(dependency); if (result == null) result = caseModelElement(dependency); if (result == null) result = caseElement(dependency); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.EXPRESSION: { Expression expression = (Expression)theEObject; T result = caseExpression(expression); if (result == null) result = caseElement(expression); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.BOOLEAN_EXPRESSION: { BooleanExpression booleanExpression = (BooleanExpression)theEObject; T result = caseBooleanExpression(booleanExpression); if (result == null) result = caseExpression(booleanExpression); if (result == null) result = caseElement(booleanExpression); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.PROCEDURE_EXPRESSION: { ProcedureExpression procedureExpression = (ProcedureExpression)theEObject; T result = caseProcedureExpression(procedureExpression); if (result == null) result = caseExpression(procedureExpression); if (result == null) result = caseElement(procedureExpression); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.MULTIPLICITY: { Multiplicity multiplicity = (Multiplicity)theEObject; T result = caseMultiplicity(multiplicity); if (result == null) result = caseElement(multiplicity); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.MULTIPLICITY_RANGE: { MultiplicityRange multiplicityRange = (MultiplicityRange)theEObject; T result = caseMultiplicityRange(multiplicityRange); if (result == null) result = caseElement(multiplicityRange); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.STEREOTYPE: { Stereotype stereotype = (Stereotype)theEObject; T result = caseStereotype(stereotype); if (result == null) result = caseModelElement(stereotype); if (result == null) result = caseElement(stereotype); if (result == null) result = defaultCase(theEObject); return result; } case CorePackage.TAGGED_VALUE: { TaggedValue taggedValue = (TaggedValue)theEObject; T result = caseTaggedValue(taggedValue); if (result == null) result = caseElement(taggedValue); if (result == null) result = defaultCase(theEObject); return result; } default: return defaultCase(theEObject); } } /** * 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>Namespace</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>Namespace</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseNamespace(Namespace object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Classifier</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>Classifier</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseClassifier(Classifier object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Class</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>Class</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseClass(orgomg.cwm.objectmodel.core.Class object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Data Type</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>Data Type</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseDataType(DataType object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Package</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>Package</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T casePackage(orgomg.cwm.objectmodel.core.Package object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Subsystem</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>Subsystem</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseSubsystem(Subsystem object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>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>Model</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseModel(Model object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Feature</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>Feature</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseFeature(Feature object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Structural Feature</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>Structural Feature</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseStructuralFeature(StructuralFeature 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>Constraint</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>Constraint</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseConstraint(Constraint object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Dependency</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>Dependency</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseDependency(Dependency object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Expression</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>Expression</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseExpression(Expression object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Boolean Expression</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>Boolean Expression</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseBooleanExpression(BooleanExpression object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Procedure Expression</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>Procedure Expression</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseProcedureExpression(ProcedureExpression object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Multiplicity</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>Multiplicity</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseMultiplicity(Multiplicity object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Multiplicity Range</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>Multiplicity Range</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseMultiplicityRange(MultiplicityRange 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>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>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; } } //CoreSwitch