| /******************************************************************************* |
| * Copyright (c) 2005, 2019 IBM Corporation and others. |
| * This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * IBM Corporation - initial API and implementation |
| *******************************************************************************/ |
| /** |
| * <copyright> |
| * </copyright> |
| * |
| * $Id: ApiSwitch.java,v 1.1 2005/01/20 12:03:04 ryman Exp $ |
| */ |
| package org.eclipse.component.api.util; |
| |
| import java.util.List; |
| |
| import org.eclipse.component.api.ApiPackage; |
| import org.eclipse.component.api.ApiTypes; |
| import org.eclipse.component.api.ClassApi; |
| import org.eclipse.component.api.ComponentApiType; |
| import org.eclipse.component.api.DocumentRoot; |
| import org.eclipse.component.api.FieldApi; |
| import org.eclipse.component.api.MethodApi; |
| |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EObject; |
| |
| /** |
| * <!-- 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.component.api.ApiPackage |
| * @generated |
| */ |
| public class ApiSwitch |
| { |
| /** |
| * The cached model package |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected static ApiPackage modelPackage; |
| |
| /** |
| * Creates an instance of the switch. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ApiSwitch() |
| { |
| if (modelPackage == null) |
| { |
| modelPackage = ApiPackage.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 Object 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 Object doSwitch(EClass theEClass, EObject theEObject) |
| { |
| if (theEClass.eContainer() == modelPackage) |
| { |
| return doSwitch(theEClass.getClassifierID(), theEObject); |
| } |
| else |
| { |
| List eSuperTypes = theEClass.getESuperTypes(); |
| return |
| eSuperTypes.isEmpty() ? |
| defaultCase(theEObject) : |
| doSwitch((EClass)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 Object doSwitch(int classifierID, EObject theEObject) |
| { |
| switch (classifierID) |
| { |
| case ApiPackage.API_TYPES: |
| { |
| ApiTypes apiTypes = (ApiTypes)theEObject; |
| Object result = caseApiTypes(apiTypes); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| case ApiPackage.CLASS_API: |
| { |
| ClassApi classApi = (ClassApi)theEObject; |
| Object result = caseClassApi(classApi); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| case ApiPackage.COMPONENT_API_TYPE: |
| { |
| ComponentApiType componentApiType = (ComponentApiType)theEObject; |
| Object result = caseComponentApiType(componentApiType); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| case ApiPackage.DOCUMENT_ROOT: |
| { |
| DocumentRoot documentRoot = (DocumentRoot)theEObject; |
| Object result = caseDocumentRoot(documentRoot); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| case ApiPackage.FIELD_API: |
| { |
| FieldApi fieldApi = (FieldApi)theEObject; |
| Object result = caseFieldApi(fieldApi); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| case ApiPackage.METHOD_API: |
| { |
| MethodApi methodApi = (MethodApi)theEObject; |
| Object result = caseMethodApi(methodApi); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| case ApiPackage.PACKAGE: |
| { |
| org.eclipse.component.api.Package package_ = (org.eclipse.component.api.Package)theEObject; |
| Object result = casePackage(package_); |
| if (result == null) result = defaultCase(theEObject); |
| return result; |
| } |
| default: return defaultCase(theEObject); |
| } |
| } |
| |
| /** |
| * Returns the result of interpretting the object as an instance of '<em>Types</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 interpretting the object as an instance of '<em>Types</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object caseApiTypes(ApiTypes object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting the object as an instance of '<em>Class Api</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 interpretting the object as an instance of '<em>Class Api</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object caseClassApi(ClassApi object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting the object as an instance of '<em>Component Api 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 interpretting the object as an instance of '<em>Component Api Type</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object caseComponentApiType(ComponentApiType object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting the object as an instance of '<em>Document Root</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 interpretting the object as an instance of '<em>Document Root</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object caseDocumentRoot(DocumentRoot object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting the object as an instance of '<em>Field Api</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 interpretting the object as an instance of '<em>Field Api</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object caseFieldApi(FieldApi object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting the object as an instance of '<em>Method Api</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 interpretting the object as an instance of '<em>Method Api</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object caseMethodApi(MethodApi object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting 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 interpretting the object as an instance of '<em>Package</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) |
| * @generated |
| */ |
| public Object casePackage(org.eclipse.component.api.Package object) |
| { |
| return null; |
| } |
| |
| /** |
| * Returns the result of interpretting 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 interpretting the object as an instance of '<em>EObject</em>'. |
| * @see #doSwitch(org.eclipse.emf.ecore.EObject) |
| * @generated |
| */ |
| public Object defaultCase(EObject object) |
| { |
| return null; |
| } |
| |
| } //ApiSwitch |