/** | |
* Copyright (c) 2009, 2011 Mia-Software. | |
* 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: | |
* Frederic Madiot (Mia-Software) - meta-model design | |
* Gregoire DUPE (Mia-Software) - design and implementation | |
* | |
* | |
* $Id$ | |
*/ | |
package org.eclipse.gmt.modisco.infra.facet.util; | |
import java.util.List; | |
import org.eclipse.emf.ecore.EAttribute; | |
import org.eclipse.emf.ecore.EClass; | |
import org.eclipse.emf.ecore.EClassifier; | |
import org.eclipse.emf.ecore.EModelElement; | |
import org.eclipse.emf.ecore.ENamedElement; | |
import org.eclipse.emf.ecore.EObject; | |
import org.eclipse.emf.ecore.EPackage; | |
import org.eclipse.emf.ecore.EReference; | |
import org.eclipse.emf.ecore.EStructuralFeature; | |
import org.eclipse.emf.ecore.ETypedElement; | |
import org.eclipse.gmt.modisco.infra.facet.*; | |
/** | |
* <!-- 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.gmt.modisco.infra.facet.FacetPackage | |
* @generated | |
* @deprecated Replaced by EMF Facet | |
*/ | |
@Deprecated | |
public class FacetSwitch<T> { | |
/** | |
* The cached model package | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected static FacetPackage modelPackage; | |
/** | |
* Creates an instance of the switch. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public FacetSwitch() { | |
if (modelPackage == null) { | |
modelPackage = FacetPackage.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 FacetPackage.FACET: { | |
Facet facet = (Facet)theEObject; | |
T result = caseFacet(facet); | |
if (result == null) result = caseEClass(facet); | |
if (result == null) result = caseEClassifier(facet); | |
if (result == null) result = caseENamedElement(facet); | |
if (result == null) result = caseEModelElement(facet); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case FacetPackage.FACET_ATTRIBUTE: { | |
FacetAttribute facetAttribute = (FacetAttribute)theEObject; | |
T result = caseFacetAttribute(facetAttribute); | |
if (result == null) result = caseEAttribute(facetAttribute); | |
if (result == null) result = caseFacetStructuralFeature(facetAttribute); | |
if (result == null) result = caseEStructuralFeature(facetAttribute); | |
if (result == null) result = caseETypedElement(facetAttribute); | |
if (result == null) result = caseENamedElement(facetAttribute); | |
if (result == null) result = caseEModelElement(facetAttribute); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case FacetPackage.FACET_REFERENCE: { | |
FacetReference facetReference = (FacetReference)theEObject; | |
T result = caseFacetReference(facetReference); | |
if (result == null) result = caseEReference(facetReference); | |
if (result == null) result = caseFacetStructuralFeature(facetReference); | |
if (result == null) result = caseEStructuralFeature(facetReference); | |
if (result == null) result = caseETypedElement(facetReference); | |
if (result == null) result = caseENamedElement(facetReference); | |
if (result == null) result = caseEModelElement(facetReference); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case FacetPackage.FACET_STRUCTURAL_FEATURE: { | |
FacetStructuralFeature facetStructuralFeature = (FacetStructuralFeature)theEObject; | |
T result = caseFacetStructuralFeature(facetStructuralFeature); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case FacetPackage.FACET_SET: { | |
FacetSet facetSet = (FacetSet)theEObject; | |
T result = caseFacetSet(facetSet); | |
if (result == null) result = caseEPackage(facetSet); | |
if (result == null) result = caseENamedElement(facetSet); | |
if (result == null) result = caseEModelElement(facetSet); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case FacetPackage.SHORTCUT: { | |
Shortcut shortcut = (Shortcut)theEObject; | |
T result = caseShortcut(shortcut); | |
if (result == null) result = caseEReference(shortcut); | |
if (result == null) result = caseEStructuralFeature(shortcut); | |
if (result == null) result = caseETypedElement(shortcut); | |
if (result == null) result = caseENamedElement(shortcut); | |
if (result == null) result = caseEModelElement(shortcut); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
default: return defaultCase(theEObject); | |
} | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Facet</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>Facet</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseFacet(Facet 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 caseFacetAttribute(FacetAttribute object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Reference</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</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseFacetReference(FacetReference object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Structural Feature</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>Structural Feature</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseFacetStructuralFeature(FacetStructuralFeature object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Set</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>Set</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseFacetSet(FacetSet object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Shortcut</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>Shortcut</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseShortcut(Shortcut object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EModel 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>EModel Element</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEModelElement(EModelElement object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>ENamed 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>ENamed Element</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseENamedElement(ENamedElement object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EClassifier</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>EClassifier</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEClassifier(EClassifier object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EClass</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>EClass</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEClass(EClass object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>ETyped 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>ETyped Element</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseETypedElement(ETypedElement object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EStructural Feature</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>EStructural Feature</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEStructuralFeature(EStructuralFeature object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EAttribute</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>EAttribute</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEAttribute(EAttribute object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EReference</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>EReference</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEReference(EReference object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>EPackage</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>EPackage</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseEPackage(EPackage 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; | |
} | |
} //FacetSwitch |