/**
* <copyright> Copyright (c) 2008-2009 Jonas Helming, Maximilian Koegel. 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 </copyright>
*/
package org.eclipse.emf.emfstore.client.test.model.classes.util;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.emfstore.client.test.model.UnicaseModelElement;
import org.eclipse.emf.emfstore.client.test.model.classes.Association;
import org.eclipse.emf.emfstore.client.test.model.classes.Attribute;
import org.eclipse.emf.emfstore.client.test.model.classes.ClassesPackage;
import org.eclipse.emf.emfstore.client.test.model.classes.Dependency;
import org.eclipse.emf.emfstore.client.test.model.classes.Enumeration;
import org.eclipse.emf.emfstore.client.test.model.classes.Literal;
import org.eclipse.emf.emfstore.client.test.model.classes.Method;
import org.eclipse.emf.emfstore.client.test.model.classes.MethodArgument;
import org.eclipse.emf.emfstore.client.test.model.classes.PackageElement;
/**
* <!-- 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.emf.emfstore.client.test.model.classes.ClassesPackage
* @generated
*/
public class ClassesSwitch<T> {
/**
* The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected static ClassesPackage modelPackage;
/**
* Creates an instance of the switch. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public ClassesSwitch() {
if (modelPackage == null) {
modelPackage = ClassesPackage.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 ClassesPackage.CLASS: {
org.eclipse.emf.emfstore.client.test.model.classes.Class class_ = (org.eclipse.emf.emfstore.client.test.model.classes.Class) theEObject;
T result = caseClass(class_);
if (result == null)
result = casePackageElement(class_);
if (result == null)
result = caseUnicaseModelElement(class_);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.PACKAGE: {
org.eclipse.emf.emfstore.client.test.model.classes.Package package_ = (org.eclipse.emf.emfstore.client.test.model.classes.Package) theEObject;
T result = casePackage(package_);
if (result == null)
result = casePackageElement(package_);
if (result == null)
result = caseUnicaseModelElement(package_);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.PACKAGE_ELEMENT: {
PackageElement packageElement = (PackageElement) theEObject;
T result = casePackageElement(packageElement);
if (result == null)
result = caseUnicaseModelElement(packageElement);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.ASSOCIATION: {
Association association = (Association) theEObject;
T result = caseAssociation(association);
if (result == null)
result = caseUnicaseModelElement(association);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.ATTRIBUTE: {
Attribute attribute = (Attribute) theEObject;
T result = caseAttribute(attribute);
if (result == null)
result = caseUnicaseModelElement(attribute);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.METHOD: {
Method method = (Method) theEObject;
T result = caseMethod(method);
if (result == null)
result = caseUnicaseModelElement(method);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.METHOD_ARGUMENT: {
MethodArgument methodArgument = (MethodArgument) theEObject;
T result = caseMethodArgument(methodArgument);
if (result == null)
result = caseUnicaseModelElement(methodArgument);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.DEPENDENCY: {
Dependency dependency = (Dependency) theEObject;
T result = caseDependency(dependency);
if (result == null)
result = caseUnicaseModelElement(dependency);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.ENUMERATION: {
Enumeration enumeration = (Enumeration) theEObject;
T result = caseEnumeration(enumeration);
if (result == null)
result = casePackageElement(enumeration);
if (result == null)
result = caseUnicaseModelElement(enumeration);
if (result == null)
result = defaultCase(theEObject);
return result;
}
case ClassesPackage.LITERAL: {
Literal literal = (Literal) theEObject;
T result = caseLiteral(literal);
if (result == null)
result = caseUnicaseModelElement(literal);
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.emf.emfstore.client.test.model.classes.Class 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.emf.emfstore.client.test.model.classes.Package object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Package 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>Package Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T casePackageElement(PackageElement object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Association</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>Association</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseAssociation(Association 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>Method</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>Method</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMethod(Method object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Method Argument</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>Method Argument</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMethodArgument(MethodArgument 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>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>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>Literal</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseLiteral(Literal object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Unicase 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>Unicase Model Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseUnicaseModelElement(UnicaseModelElement 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;
}
} // ClassesSwitch