blob: 4690b31f58e24ec60194a9ccdecb74e65c1e5743 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2007, 2010 BMW Car IT, Technische Universitaet Muenchen, 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:
* BMW Car IT - Initial API and implementation
* Technische Universitaet Muenchen - Major refactoring and extension
*******************************************************************************/
package org.eclipse.emf.edapt.spi.migration.util;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edapt.spi.migration.AbstractResource;
import org.eclipse.emf.edapt.spi.migration.AttributeSlot;
import org.eclipse.emf.edapt.spi.migration.Instance;
import org.eclipse.emf.edapt.spi.migration.Metamodel;
import org.eclipse.emf.edapt.spi.migration.MetamodelResource;
import org.eclipse.emf.edapt.spi.migration.MigrationPackage;
import org.eclipse.emf.edapt.spi.migration.Model;
import org.eclipse.emf.edapt.spi.migration.ModelResource;
import org.eclipse.emf.edapt.spi.migration.ReferenceSlot;
import org.eclipse.emf.edapt.spi.migration.Repository;
import org.eclipse.emf.edapt.spi.migration.Slot;
import org.eclipse.emf.edapt.spi.migration.Type;
/**
* <!-- 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.edapt.spi.migration.MigrationPackage
* @generated
*/
public class MigrationSwitch<T> {
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
protected static MigrationPackage modelPackage;
/**
* Creates an instance of the switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
*
* @generated
*/
public MigrationSwitch() {
if (modelPackage == null) {
modelPackage = MigrationPackage.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);
}
final 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 MigrationPackage.REPOSITORY: {
final Repository repository = (Repository) theEObject;
T result = caseRepository(repository);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.MODEL: {
final Model model = (Model) theEObject;
T result = caseModel(model);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.MODEL_RESOURCE: {
final ModelResource modelResource = (ModelResource) theEObject;
T result = caseModelResource(modelResource);
if (result == null) {
result = caseAbstractResource(modelResource);
}
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.TYPE: {
final Type type = (Type) theEObject;
T result = caseType(type);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.INSTANCE: {
final Instance instance = (Instance) theEObject;
T result = caseInstance(instance);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.SLOT: {
final Slot slot = (Slot) theEObject;
T result = caseSlot(slot);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.ATTRIBUTE_SLOT: {
final AttributeSlot attributeSlot = (AttributeSlot) theEObject;
T result = caseAttributeSlot(attributeSlot);
if (result == null) {
result = caseSlot(attributeSlot);
}
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.REFERENCE_SLOT: {
final ReferenceSlot referenceSlot = (ReferenceSlot) theEObject;
T result = caseReferenceSlot(referenceSlot);
if (result == null) {
result = caseSlot(referenceSlot);
}
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.METAMODEL: {
final Metamodel metamodel = (Metamodel) theEObject;
T result = caseMetamodel(metamodel);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.METAMODEL_RESOURCE: {
final MetamodelResource metamodelResource = (MetamodelResource) theEObject;
T result = caseMetamodelResource(metamodelResource);
if (result == null) {
result = caseAbstractResource(metamodelResource);
}
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
case MigrationPackage.ABSTRACT_RESOURCE: {
final AbstractResource abstractResource = (AbstractResource) theEObject;
T result = caseAbstractResource(abstractResource);
if (result == null) {
result = defaultCase(theEObject);
}
return result;
}
default:
return defaultCase(theEObject);
}
}
/**
* 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>Metamodel</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>Metamodel</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMetamodel(Metamodel 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>Instance</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>Instance</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseInstance(Instance object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Slot</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>Slot</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseSlot(Slot object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Attribute Slot</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 Slot</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseAttributeSlot(AttributeSlot object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Reference Slot</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>Reference Slot</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseReferenceSlot(ReferenceSlot object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Repository</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>Repository</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseRepository(Repository object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Model Resource</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 Resource</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseModelResource(ModelResource object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Abstract Resource</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>Abstract Resource</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseAbstractResource(AbstractResource object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Metamodel Resource</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>Metamodel Resource</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseMetamodelResource(MetamodelResource 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;
}
} // MigrationSwitch