/** * Copyright (c) 2011 Obeo. * 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: * Obeo - initial API and implementation */ package org.obeonetwork.dsl.database.util; import java.util.List; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.obeonetwork.dsl.database.*; import org.obeonetwork.dsl.typeslibrary.TypesLibraryUser; /** * <!-- 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.obeonetwork.dsl.database.DatabasePackage * @generated */ public class DatabaseSwitch<T> { /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static final String copyright = "Copyright (c) 2011 Obeo.\r\nAll rights reserved. This program and the accompanying materials\r\nare made available under the terms of the Eclipse Public License v1.0\r\nwhich accompanies this distribution, and is available at\r\nhttp://www.eclipse.org/legal/epl-v10.html\r\n\r\nContributors:\r\n Obeo - initial API and implementation"; /** * The cached model package * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected static DatabasePackage modelPackage; /** * Creates an instance of the switch. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public DatabaseSwitch() { if (modelPackage == null) { modelPackage = DatabasePackage.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 DatabasePackage.NAMED_ELEMENT: { NamedElement namedElement = (NamedElement)theEObject; T result = caseNamedElement(namedElement); if (result == null) result = caseDatabaseElement(namedElement); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.DATA_BASE: { DataBase dataBase = (DataBase)theEObject; T result = caseDataBase(dataBase); if (result == null) result = caseTableContainer(dataBase); if (result == null) result = caseTypesLibraryUser(dataBase); if (result == null) result = caseNamedElement(dataBase); if (result == null) result = caseDatabaseElement(dataBase); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.ABSTRACT_TABLE: { AbstractTable abstractTable = (AbstractTable)theEObject; T result = caseAbstractTable(abstractTable); if (result == null) result = caseNamedElement(abstractTable); if (result == null) result = caseDatabaseElement(abstractTable); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.COLUMN: { Column column = (Column)theEObject; T result = caseColumn(column); if (result == null) result = caseNamedElement(column); if (result == null) result = caseDatabaseElement(column); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.INDEX: { Index index = (Index)theEObject; T result = caseIndex(index); if (result == null) result = caseNamedElement(index); if (result == null) result = caseDatabaseElement(index); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.VIEW: { View view = (View)theEObject; T result = caseView(view); if (result == null) result = caseAbstractTable(view); if (result == null) result = caseNamedElement(view); if (result == null) result = caseDatabaseElement(view); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.TABLE: { Table table = (Table)theEObject; T result = caseTable(table); if (result == null) result = caseAbstractTable(table); if (result == null) result = caseNamedElement(table); if (result == null) result = caseDatabaseElement(table); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.PRIMARY_KEY: { PrimaryKey primaryKey = (PrimaryKey)theEObject; T result = casePrimaryKey(primaryKey); if (result == null) result = caseNamedElement(primaryKey); if (result == null) result = caseDatabaseElement(primaryKey); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.FOREIGN_KEY: { ForeignKey foreignKey = (ForeignKey)theEObject; T result = caseForeignKey(foreignKey); if (result == null) result = caseNamedElement(foreignKey); if (result == null) result = caseDatabaseElement(foreignKey); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.FOREIGN_KEY_ELEMENT: { ForeignKeyElement foreignKeyElement = (ForeignKeyElement)theEObject; T result = caseForeignKeyElement(foreignKeyElement); if (result == null) result = caseDatabaseElement(foreignKeyElement); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.INDEX_ELEMENT: { IndexElement indexElement = (IndexElement)theEObject; T result = caseIndexElement(indexElement); if (result == null) result = caseDatabaseElement(indexElement); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.CONSTRAINT: { Constraint constraint = (Constraint)theEObject; T result = caseConstraint(constraint); if (result == null) result = caseNamedElement(constraint); if (result == null) result = caseDatabaseElement(constraint); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.DATABASE_ELEMENT: { DatabaseElement databaseElement = (DatabaseElement)theEObject; T result = caseDatabaseElement(databaseElement); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.SCHEMA: { Schema schema = (Schema)theEObject; T result = caseSchema(schema); if (result == null) result = caseTableContainer(schema); if (result == null) result = caseNamedElement(schema); if (result == null) result = caseDatabaseElement(schema); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.SEQUENCE: { Sequence sequence = (Sequence)theEObject; T result = caseSequence(sequence); if (result == null) result = caseNamedElement(sequence); if (result == null) result = caseDatabaseElement(sequence); if (result == null) result = defaultCase(theEObject); return result; } case DatabasePackage.TABLE_CONTAINER: { TableContainer tableContainer = (TableContainer)theEObject; T result = caseTableContainer(tableContainer); if (result == null) result = caseNamedElement(tableContainer); if (result == null) result = caseDatabaseElement(tableContainer); if (result == null) result = defaultCase(theEObject); return result; } default: return defaultCase(theEObject); } } /** * 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>Data Base</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 Base</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseDataBase(DataBase object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Abstract Table</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 Table</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseAbstractTable(AbstractTable object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Column</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>Column</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseColumn(Column object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Index</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>Index</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseIndex(Index object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>View</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>View</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseView(View object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Table</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>Table</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseTable(Table object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Primary Key</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>Primary Key</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T casePrimaryKey(PrimaryKey object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Foreign Key</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>Foreign Key</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseForeignKey(ForeignKey object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Foreign Key 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>Foreign Key Element</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseForeignKeyElement(ForeignKeyElement object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Index 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>Index Element</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseIndexElement(IndexElement 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>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 caseDatabaseElement(DatabaseElement object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Schema</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>Schema</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseSchema(Schema object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>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>Sequence</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseSequence(Sequence object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Table Container</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>Table Container</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseTableContainer(TableContainer object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>User</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>User</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseTypesLibraryUser(TypesLibraryUser 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; } } //DatabaseSwitch