blob: 411f99c642dc7b8bb751652e1e1c33155b7021ed [file] [log] [blame]
/**
* *******************************************************************************
* Copyright (c) 2008 Hatha Systems.
* 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:
* Nikolai Mansourov (Hatha Systems) - initial API and implementation
* *******************************************************************************
*
* $Id$
*/
package org.eclipse.gmt.modisco.omg.kdm.structure.util;
import java.util.List;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmt.modisco.omg.kdm.core.Element;
import org.eclipse.gmt.modisco.omg.kdm.core.KDMEntity;
import org.eclipse.gmt.modisco.omg.kdm.core.KDMRelationship;
import org.eclipse.gmt.modisco.omg.kdm.core.ModelElement;
import org.eclipse.gmt.modisco.omg.kdm.kdm.KDMFramework;
import org.eclipse.gmt.modisco.omg.kdm.kdm.KDMModel;
import org.eclipse.gmt.modisco.omg.kdm.structure.AbstractStructureElement;
import org.eclipse.gmt.modisco.omg.kdm.structure.AbstractStructureRelationship;
import org.eclipse.gmt.modisco.omg.kdm.structure.ArchitectureView;
import org.eclipse.gmt.modisco.omg.kdm.structure.Component;
import org.eclipse.gmt.modisco.omg.kdm.structure.Layer;
import org.eclipse.gmt.modisco.omg.kdm.structure.SoftwareSystem;
import org.eclipse.gmt.modisco.omg.kdm.structure.StructureElement;
import org.eclipse.gmt.modisco.omg.kdm.structure.StructureModel;
import org.eclipse.gmt.modisco.omg.kdm.structure.StructurePackage;
import org.eclipse.gmt.modisco.omg.kdm.structure.StructureRelationship;
import org.eclipse.gmt.modisco.omg.kdm.structure.Subsystem;
/**
* <!-- 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.omg.kdm.structure.StructurePackage
* @generated
*/
public class StructureSwitch<T> {
/**
* The cached model package
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected static StructurePackage modelPackage;
/**
* Creates an instance of the switch.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public StructureSwitch() {
if (modelPackage == null) {
modelPackage = StructurePackage.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 StructurePackage.ABSTRACT_STRUCTURE_ELEMENT: {
AbstractStructureElement abstractStructureElement = (AbstractStructureElement)theEObject;
T result = caseAbstractStructureElement(abstractStructureElement);
if (result == null) result = caseKDMEntity(abstractStructureElement);
if (result == null) result = caseModelElement(abstractStructureElement);
if (result == null) result = caseElement(abstractStructureElement);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.SUBSYSTEM: {
Subsystem subsystem = (Subsystem)theEObject;
T result = caseSubsystem(subsystem);
if (result == null) result = caseAbstractStructureElement(subsystem);
if (result == null) result = caseKDMEntity(subsystem);
if (result == null) result = caseModelElement(subsystem);
if (result == null) result = caseElement(subsystem);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.LAYER: {
Layer layer = (Layer)theEObject;
T result = caseLayer(layer);
if (result == null) result = caseAbstractStructureElement(layer);
if (result == null) result = caseKDMEntity(layer);
if (result == null) result = caseModelElement(layer);
if (result == null) result = caseElement(layer);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.STRUCTURE_MODEL: {
StructureModel structureModel = (StructureModel)theEObject;
T result = caseStructureModel(structureModel);
if (result == null) result = caseKDMModel(structureModel);
if (result == null) result = caseKDMFramework(structureModel);
if (result == null) result = caseModelElement(structureModel);
if (result == null) result = caseElement(structureModel);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.COMPONENT: {
Component component = (Component)theEObject;
T result = caseComponent(component);
if (result == null) result = caseAbstractStructureElement(component);
if (result == null) result = caseKDMEntity(component);
if (result == null) result = caseModelElement(component);
if (result == null) result = caseElement(component);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.SOFTWARE_SYSTEM: {
SoftwareSystem softwareSystem = (SoftwareSystem)theEObject;
T result = caseSoftwareSystem(softwareSystem);
if (result == null) result = caseAbstractStructureElement(softwareSystem);
if (result == null) result = caseKDMEntity(softwareSystem);
if (result == null) result = caseModelElement(softwareSystem);
if (result == null) result = caseElement(softwareSystem);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.ABSTRACT_STRUCTURE_RELATIONSHIP: {
AbstractStructureRelationship abstractStructureRelationship = (AbstractStructureRelationship)theEObject;
T result = caseAbstractStructureRelationship(abstractStructureRelationship);
if (result == null) result = caseKDMRelationship(abstractStructureRelationship);
if (result == null) result = caseModelElement(abstractStructureRelationship);
if (result == null) result = caseElement(abstractStructureRelationship);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.STRUCTURE_RELATIONSHIP: {
StructureRelationship structureRelationship = (StructureRelationship)theEObject;
T result = caseStructureRelationship(structureRelationship);
if (result == null) result = caseAbstractStructureRelationship(structureRelationship);
if (result == null) result = caseKDMRelationship(structureRelationship);
if (result == null) result = caseModelElement(structureRelationship);
if (result == null) result = caseElement(structureRelationship);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.ARCHITECTURE_VIEW: {
ArchitectureView architectureView = (ArchitectureView)theEObject;
T result = caseArchitectureView(architectureView);
if (result == null) result = caseAbstractStructureElement(architectureView);
if (result == null) result = caseKDMEntity(architectureView);
if (result == null) result = caseModelElement(architectureView);
if (result == null) result = caseElement(architectureView);
if (result == null) result = defaultCase(theEObject);
return result;
}
case StructurePackage.STRUCTURE_ELEMENT: {
StructureElement structureElement = (StructureElement)theEObject;
T result = caseStructureElement(structureElement);
if (result == null) result = caseAbstractStructureElement(structureElement);
if (result == null) result = caseKDMEntity(structureElement);
if (result == null) result = caseModelElement(structureElement);
if (result == null) result = caseElement(structureElement);
if (result == null) result = defaultCase(theEObject);
return result;
}
default: return defaultCase(theEObject);
}
}
/**
* Returns the result of interpreting the object as an instance of '<em>Abstract Structure 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>Abstract Structure Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseAbstractStructureElement(AbstractStructureElement object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Subsystem</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>Subsystem</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseSubsystem(Subsystem object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Layer</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>Layer</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseLayer(Layer object) {
return null;
}
/**
* 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 caseStructureModel(StructureModel object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Component</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>Component</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseComponent(Component object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Software System</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>Software System</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseSoftwareSystem(SoftwareSystem object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Abstract Structure Relationship</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 Structure Relationship</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseAbstractStructureRelationship(AbstractStructureRelationship object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Relationship</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>Relationship</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseStructureRelationship(StructureRelationship object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Architecture 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>Architecture View</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseArchitectureView(ArchitectureView 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 caseStructureElement(StructureElement 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 caseElement(Element object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>Model 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>Model Element</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseModelElement(ModelElement object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>KDM Entity</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>KDM Entity</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseKDMEntity(KDMEntity object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>KDM Framework</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>KDM Framework</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseKDMFramework(KDMFramework object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>KDM 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>KDM Model</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseKDMModel(KDMModel object) {
return null;
}
/**
* Returns the result of interpreting the object as an instance of '<em>KDM Relationship</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>KDM Relationship</em>'.
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
* @generated
*/
public T caseKDMRelationship(KDMRelationship 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;
}
} //StructureSwitch