blob: c87c7071c4a84e798aad8b1ae88710856cf221e6 [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2007, 2008 E.D.Willink and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* E.D.Willink - initial API and implementation
*
* </copyright>
*
* $Id: EMOFSwitch.java,v 1.1 2008/07/23 09:55:17 qglineur Exp $
*/
package org.eclipse.qvt.declarative.emof.EMOF.util;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.qvt.declarative.emof.EMOF.Comment;
import org.eclipse.qvt.declarative.emof.EMOF.DataType;
import org.eclipse.qvt.declarative.emof.EMOF.EMOFPackage;
import org.eclipse.qvt.declarative.emof.EMOF.Element;
import org.eclipse.qvt.declarative.emof.EMOF.Enumeration;
import org.eclipse.qvt.declarative.emof.EMOF.EnumerationLiteral;
import org.eclipse.qvt.declarative.emof.EMOF.Extent;
import org.eclipse.qvt.declarative.emof.EMOF.Factory;
import org.eclipse.qvt.declarative.emof.EMOF.MultiplicityElement;
import org.eclipse.qvt.declarative.emof.EMOF.NamedElement;
import org.eclipse.qvt.declarative.emof.EMOF.Operation;
import org.eclipse.qvt.declarative.emof.EMOF.Parameter;
import org.eclipse.qvt.declarative.emof.EMOF.PrimitiveType;
import org.eclipse.qvt.declarative.emof.EMOF.Property;
import org.eclipse.qvt.declarative.emof.EMOF.ReflectiveCollection;
import org.eclipse.qvt.declarative.emof.EMOF.ReflectiveSequence;
import org.eclipse.qvt.declarative.emof.EMOF.Tag;
import org.eclipse.qvt.declarative.emof.EMOF.Type;
import org.eclipse.qvt.declarative.emof.EMOF.TypedElement;
import org.eclipse.qvt.declarative.emof.EMOF.URIExtent;
/**
* <!-- 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.qvt.declarative.emof.EMOF.EMOFPackage
* @generated
*/
public class EMOFSwitch<T> {
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static EMOFPackage modelPackage;
/**
* Creates an instance of the switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public EMOFSwitch() {
if (modelPackage == null) {
modelPackage = EMOFPackage.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 EMOFPackage.CLASS: {
org.eclipse.qvt.declarative.emof.EMOF.Class class_ = (org.eclipse.qvt.declarative.emof.EMOF.Class)theEObject;
T result = caseClass(class_);
if (result == null) result = caseType(class_);
if (result == null) result = caseNamedElement(class_);
if (result == null) result = caseElement(class_);
if (result == null) result = caseObject(class_);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.COMMENT: {
Comment comment = (Comment)theEObject;
T result = caseComment(comment);
if (result == null) result = caseElement(comment);
if (result == null) result = caseObject(comment);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.DATA_TYPE: {
DataType dataType = (DataType)theEObject;
T result = caseDataType(dataType);
if (result == null) result = caseType(dataType);
if (result == null) result = caseNamedElement(dataType);
if (result == null) result = caseElement(dataType);
if (result == null) result = caseObject(dataType);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.ELEMENT: {
Element element = (Element)theEObject;
T result = caseElement(element);
if (result == null) result = caseObject(element);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.ENUMERATION: {
Enumeration enumeration = (Enumeration)theEObject;
T result = caseEnumeration(enumeration);
if (result == null) result = caseDataType(enumeration);
if (result == null) result = caseType(enumeration);
if (result == null) result = caseNamedElement(enumeration);
if (result == null) result = caseElement(enumeration);
if (result == null) result = caseObject(enumeration);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.ENUMERATION_LITERAL: {
EnumerationLiteral enumerationLiteral = (EnumerationLiteral)theEObject;
T result = caseEnumerationLiteral(enumerationLiteral);
if (result == null) result = caseNamedElement(enumerationLiteral);
if (result == null) result = caseElement(enumerationLiteral);
if (result == null) result = caseObject(enumerationLiteral);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.EXTENT: {
Extent extent = (Extent)theEObject;
T result = caseExtent(extent);
if (result == null) result = caseObject(extent);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.FACTORY: {
Factory factory = (Factory)theEObject;
T result = caseFactory(factory);
if (result == null) result = caseElement(factory);
if (result == null) result = caseObject(factory);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.MULTIPLICITY_ELEMENT: {
MultiplicityElement multiplicityElement = (MultiplicityElement)theEObject;
T result = caseMultiplicityElement(multiplicityElement);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.NAMED_ELEMENT: {
NamedElement namedElement = (NamedElement)theEObject;
T result = caseNamedElement(namedElement);
if (result == null) result = caseElement(namedElement);
if (result == null) result = caseObject(namedElement);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.OBJECT: {
org.eclipse.qvt.declarative.emof.EMOF.Object object = (org.eclipse.qvt.declarative.emof.EMOF.Object)theEObject;
T result = caseObject(object);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.OPERATION: {
Operation operation = (Operation)theEObject;
T result = caseOperation(operation);
if (result == null) result = caseTypedElement(operation);
if (result == null) result = caseMultiplicityElement(operation);
if (result == null) result = caseNamedElement(operation);
if (result == null) result = caseElement(operation);
if (result == null) result = caseObject(operation);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.PACKAGE: {
org.eclipse.qvt.declarative.emof.EMOF.Package package_ = (org.eclipse.qvt.declarative.emof.EMOF.Package)theEObject;
T result = casePackage(package_);
if (result == null) result = caseNamedElement(package_);
if (result == null) result = caseElement(package_);
if (result == null) result = caseObject(package_);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.PARAMETER: {
Parameter parameter = (Parameter)theEObject;
T result = caseParameter(parameter);
if (result == null) result = caseTypedElement(parameter);
if (result == null) result = caseMultiplicityElement(parameter);
if (result == null) result = caseNamedElement(parameter);
if (result == null) result = caseElement(parameter);
if (result == null) result = caseObject(parameter);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.PRIMITIVE_TYPE: {
PrimitiveType primitiveType = (PrimitiveType)theEObject;
T result = casePrimitiveType(primitiveType);
if (result == null) result = caseDataType(primitiveType);
if (result == null) result = caseType(primitiveType);
if (result == null) result = caseNamedElement(primitiveType);
if (result == null) result = caseElement(primitiveType);
if (result == null) result = caseObject(primitiveType);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.PROPERTY: {
Property property = (Property)theEObject;
T result = caseProperty(property);
if (result == null) result = caseTypedElement(property);
if (result == null) result = caseMultiplicityElement(property);
if (result == null) result = caseNamedElement(property);
if (result == null) result = caseElement(property);
if (result == null) result = caseObject(property);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.REFLECTIVE_COLLECTION: {
ReflectiveCollection reflectiveCollection = (ReflectiveCollection)theEObject;
T result = caseReflectiveCollection(reflectiveCollection);
if (result == null) result = caseObject(reflectiveCollection);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.REFLECTIVE_SEQUENCE: {
ReflectiveSequence reflectiveSequence = (ReflectiveSequence)theEObject;
T result = caseReflectiveSequence(reflectiveSequence);
if (result == null) result = caseReflectiveCollection(reflectiveSequence);
if (result == null) result = caseObject(reflectiveSequence);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.TAG: {
Tag tag = (Tag)theEObject;
T result = caseTag(tag);
if (result == null) result = caseElement(tag);
if (result == null) result = caseObject(tag);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.TYPE: {
Type type = (Type)theEObject;
T result = caseType(type);
if (result == null) result = caseNamedElement(type);
if (result == null) result = caseElement(type);
if (result == null) result = caseObject(type);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.TYPED_ELEMENT: {
TypedElement typedElement = (TypedElement)theEObject;
T result = caseTypedElement(typedElement);
if (result == null) result = caseNamedElement(typedElement);
if (result == null) result = caseElement(typedElement);
if (result == null) result = caseObject(typedElement);
if (result == null) result = defaultCase(theEObject);
return result;
}
case EMOFPackage.URI_EXTENT: {
URIExtent uriExtent = (URIExtent)theEObject;
T result = caseURIExtent(uriExtent);
if (result == null) result = caseExtent(uriExtent);
if (result == null) result = caseObject(uriExtent);
if (result == null) result = defaultCase(theEObject);
return result;
}
default: return defaultCase(theEObject);
}
}
/**
* 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(org.eclipse.qvt.declarative.emof.EMOF.Class object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Comment</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>Comment</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseComment(Comment 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>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>Enumeration</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>Enumeration</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseEnumeration(Enumeration object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Enumeration Literal</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>Enumeration Literal</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseEnumerationLiteral(EnumerationLiteral object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Extent</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>Extent</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseExtent(Extent object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Factory</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>Factory</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseFactory(Factory object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Multiplicity 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>Multiplicity Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMultiplicityElement(MultiplicityElement object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Named 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>Named Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseNamedElement(NamedElement object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Object</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>Object</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseObject(org.eclipse.qvt.declarative.emof.EMOF.Object object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Operation</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>Operation</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseOperation(Operation 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(org.eclipse.qvt.declarative.emof.EMOF.Package object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Parameter</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>Parameter</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseParameter(Parameter object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Primitive 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>Primitive Type</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T casePrimitiveType(PrimitiveType object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Property</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>Property</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseProperty(Property object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Reflective Collection</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>Reflective Collection</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseReflectiveCollection(ReflectiveCollection object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Reflective Sequence</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>Reflective Sequence</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseReflectiveSequence(ReflectiveSequence object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Tag</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</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseTag(Tag object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>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>Type</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseType(Type object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Typed 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>Typed Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseTypedElement(TypedElement object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>URI Extent</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>URI Extent</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseURIExtent(URIExtent 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;
}
} //EMOFSwitch