/** * 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.typeslibrary.util; import java.util.List; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.obeonetwork.dsl.typeslibrary.*; /** * <!-- 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.typeslibrary.TypesLibraryPackage * @generated */ public class TypesLibrarySwitch<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 TypesLibraryPackage modelPackage; /** * Creates an instance of the switch. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public TypesLibrarySwitch() { if (modelPackage == null) { modelPackage = TypesLibraryPackage.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 TypesLibraryPackage.NATIVE_TYPES_LIBRARY: { NativeTypesLibrary nativeTypesLibrary = (NativeTypesLibrary)theEObject; T result = caseNativeTypesLibrary(nativeTypesLibrary); if (result == null) result = caseTypesLibrary(nativeTypesLibrary); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.TYPE_INSTANCE: { TypeInstance typeInstance = (TypeInstance)theEObject; T result = caseTypeInstance(typeInstance); if (result == null) result = caseType(typeInstance); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.NATIVE_TYPE: { NativeType nativeType = (NativeType)theEObject; T result = caseNativeType(nativeType); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.COMPLEX_NAMED_TYPE: { ComplexNamedType complexNamedType = (ComplexNamedType)theEObject; T result = caseComplexNamedType(complexNamedType); if (result == null) result = caseUserDefinedType(complexNamedType); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.SIMPLE_NAMED_TYPE: { SimpleNamedType simpleNamedType = (SimpleNamedType)theEObject; T result = caseSimpleNamedType(simpleNamedType); if (result == null) result = caseUserDefinedType(simpleNamedType); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.TYPE: { Type type = (Type)theEObject; T result = caseType(type); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.USER_DEFINED_TYPE: { UserDefinedType userDefinedType = (UserDefinedType)theEObject; T result = caseUserDefinedType(userDefinedType); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.USER_DEFINED_TYPE_REF: { UserDefinedTypeRef userDefinedTypeRef = (UserDefinedTypeRef)theEObject; T result = caseUserDefinedTypeRef(userDefinedTypeRef); if (result == null) result = caseType(userDefinedTypeRef); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.USER_DEFINED_TYPES_LIBRARY: { UserDefinedTypesLibrary userDefinedTypesLibrary = (UserDefinedTypesLibrary)theEObject; T result = caseUserDefinedTypesLibrary(userDefinedTypesLibrary); if (result == null) result = caseTypesLibrary(userDefinedTypesLibrary); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.TYPES_LIBRARY_USER: { TypesLibraryUser typesLibraryUser = (TypesLibraryUser)theEObject; T result = caseTypesLibraryUser(typesLibraryUser); if (result == null) result = defaultCase(theEObject); return result; } case TypesLibraryPackage.TYPES_LIBRARY: { TypesLibrary typesLibrary = (TypesLibrary)theEObject; T result = caseTypesLibrary(typesLibrary); if (result == null) result = defaultCase(theEObject); return result; } default: return defaultCase(theEObject); } } /** * Returns the result of interpreting the object as an instance of '<em>Native Types Library</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>Native Types Library</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseNativeTypesLibrary(NativeTypesLibrary object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Type 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>Type Instance</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseTypeInstance(TypeInstance object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Native 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>Native Type</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseNativeType(NativeType object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Complex Named 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>Complex Named Type</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseComplexNamedType(ComplexNamedType object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Simple Named 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>Simple Named Type</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseSimpleNamedType(SimpleNamedType 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>User Defined 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>User Defined Type</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseUserDefinedType(UserDefinedType object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>User Defined Type Ref</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 Defined Type Ref</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseUserDefinedTypeRef(UserDefinedTypeRef object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>User Defined Types Library</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 Defined Types Library</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseUserDefinedTypesLibrary(UserDefinedTypesLibrary 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>Types Library</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>Types Library</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseTypesLibrary(TypesLibrary 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; } } //TypesLibrarySwitch