/** * Copyright (c) 2008-2011 Chair for Applied Software Engineering, * Technische Universitaet Muenchen. * 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: */ package org.eclipse.emf.emfstore.bowling.util; import java.util.List; import java.util.Map; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.emfstore.bowling.Area; import org.eclipse.emf.emfstore.bowling.BowlingPackage; import org.eclipse.emf.emfstore.bowling.Fan; import org.eclipse.emf.emfstore.bowling.Game; import org.eclipse.emf.emfstore.bowling.League; import org.eclipse.emf.emfstore.bowling.Matchup; import org.eclipse.emf.emfstore.bowling.Merchandise; import org.eclipse.emf.emfstore.bowling.Player; import org.eclipse.emf.emfstore.bowling.Referee; import org.eclipse.emf.emfstore.bowling.Tournament; /** * <!-- 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.emf.emfstore.bowling.BowlingPackage * @generated */ public class BowlingSwitch<T> { /** * The cached model package * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ protected static BowlingPackage modelPackage; /** * Creates an instance of the switch. * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public BowlingSwitch() { if (modelPackage == null) { modelPackage = BowlingPackage.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); } final 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 BowlingPackage.PLAYER: { final Player player = (Player) theEObject; T result = casePlayer(player); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.LEAGUE: { final League league = (League) theEObject; T result = caseLeague(league); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.TOURNAMENT: { final Tournament tournament = (Tournament) theEObject; T result = caseTournament(tournament); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.MATCHUP: { final Matchup matchup = (Matchup) theEObject; T result = caseMatchup(matchup); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.GAME: { final Game game = (Game) theEObject; T result = caseGame(game); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.PLAYER_TO_POINTS_MAP: { @SuppressWarnings("unchecked") final Map.Entry<Player, Integer> playerToPointsMap = (Map.Entry<Player, Integer>) theEObject; T result = casePlayerToPointsMap(playerToPointsMap); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.REFEREE: { final Referee referee = (Referee) theEObject; T result = caseReferee(referee); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.REFEREE_TO_GAMES_MAP: { @SuppressWarnings("unchecked") final Map.Entry<Referee, Game> refereeToGamesMap = (Map.Entry<Referee, Game>) theEObject; T result = caseRefereeToGamesMap(refereeToGamesMap); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.AREA: { final Area area = (Area) theEObject; T result = caseArea(area); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.FAN: { final Fan fan = (Fan) theEObject; T result = caseFan(fan); if (result == null) { result = defaultCase(theEObject); } return result; } case BowlingPackage.MERCHANDISE: { final Merchandise merchandise = (Merchandise) theEObject; T result = caseMerchandise(merchandise); if (result == null) { result = defaultCase(theEObject); } return result; } default: return defaultCase(theEObject); } } /** * Returns the result of interpreting the object as an instance of '<em>Player</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>Player</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T casePlayer(Player object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>League</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>League</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseLeague(League object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Tournament</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>Tournament</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseTournament(Tournament object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Matchup</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>Matchup</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseMatchup(Matchup object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Game</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>Game</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseGame(Game object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Player To Points Map</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>Player To Points Map</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T casePlayerToPointsMap(Map.Entry<Player, Integer> object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Referee</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>Referee</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseReferee(Referee object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Referee To Games Map</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>Referee To Games Map</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseRefereeToGamesMap(Map.Entry<Referee, Game> object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Area</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>Area</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseArea(Area object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Fan</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>Fan</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseFan(Fan object) { return null; } /** * Returns the result of interpreting the object as an instance of '<em>Merchandise</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>Merchandise</em>'. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) * @generated */ public T caseMerchandise(Merchandise 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; } } // BowlingSwitch