/******************************************************************************* | |
* Copyright (c) 2010, 2012 Ericsson | |
* | |
* 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 | |
* | |
* Description: | |
* | |
* Contributors: | |
* Alvaro Sanchez-Leon - Initial Implementation and API | |
*******************************************************************************/ | |
package org.eclipse.mylyn.reviews.frame.core.model.util; | |
import java.util.List; | |
import org.eclipse.emf.ecore.EClass; | |
import org.eclipse.emf.ecore.EObject; | |
import org.eclipse.mylyn.reviews.frame.core.model.*; | |
import org.eclipse.mylyn.reviews.frame.core.model.Comment; | |
import org.eclipse.mylyn.reviews.frame.core.model.CommentType; | |
import org.eclipse.mylyn.reviews.frame.core.model.Item; | |
import org.eclipse.mylyn.reviews.frame.core.model.Location; | |
import org.eclipse.mylyn.reviews.frame.core.model.ModelPackage; | |
import org.eclipse.mylyn.reviews.frame.core.model.Review; | |
import org.eclipse.mylyn.reviews.frame.core.model.ReviewComponent; | |
import org.eclipse.mylyn.reviews.frame.core.model.ReviewGroup; | |
import org.eclipse.mylyn.reviews.frame.core.model.ReviewState; | |
import org.eclipse.mylyn.reviews.frame.core.model.TaskReference; | |
import org.eclipse.mylyn.reviews.frame.core.model.Topic; | |
import org.eclipse.mylyn.reviews.frame.core.model.User; | |
public class ModelSwitch<T> { | |
/** | |
* The cached model package | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
protected static ModelPackage modelPackage; | |
/** | |
* Creates an instance of the switch. | |
* <!-- begin-user-doc --> | |
* <!-- end-user-doc --> | |
* @generated | |
*/ | |
public ModelSwitch() { | |
if (modelPackage == null) { | |
modelPackage = ModelPackage.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 ModelPackage.REVIEW: { | |
Review review = (Review)theEObject; | |
T result = caseReview(review); | |
if (result == null) result = caseReviewComponent(review); | |
if (result == null) result = caseSubModelRoot(review); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.COMMENT: { | |
Comment comment = (Comment)theEObject; | |
T result = caseComment(comment); | |
if (result == null) result = caseReviewComponent(comment); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.ITEM: { | |
Item item = (Item)theEObject; | |
T result = caseItem(item); | |
if (result == null) result = caseReviewComponent(item); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.LOCATION: { | |
Location location = (Location)theEObject; | |
T result = caseLocation(location); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.USER: { | |
User user = (User)theEObject; | |
T result = caseUser(user); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.TASK_REFERENCE: { | |
TaskReference taskReference = (TaskReference)theEObject; | |
T result = caseTaskReference(taskReference); | |
if (result == null) result = caseReviewComponent(taskReference); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.REVIEW_STATE: { | |
ReviewState reviewState = (ReviewState)theEObject; | |
T result = caseReviewState(reviewState); | |
if (result == null) result = caseReviewComponent(reviewState); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.REVIEW_GROUP: { | |
ReviewGroup reviewGroup = (ReviewGroup)theEObject; | |
T result = caseReviewGroup(reviewGroup); | |
if (result == null) result = caseReviewComponent(reviewGroup); | |
if (result == null) result = caseSubModelRoot(reviewGroup); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.COMMENT_TYPE: { | |
CommentType commentType = (CommentType)theEObject; | |
T result = caseCommentType(commentType); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.TOPIC: { | |
Topic topic = (Topic)theEObject; | |
T result = caseTopic(topic); | |
if (result == null) result = caseComment(topic); | |
if (result == null) result = caseReviewComponent(topic); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.REVIEW_COMPONENT: { | |
ReviewComponent reviewComponent = (ReviewComponent)theEObject; | |
T result = caseReviewComponent(reviewComponent); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
case ModelPackage.SUB_MODEL_ROOT: { | |
SubModelRoot subModelRoot = (SubModelRoot)theEObject; | |
T result = caseSubModelRoot(subModelRoot); | |
if (result == null) result = defaultCase(theEObject); | |
return result; | |
} | |
default: return defaultCase(theEObject); | |
} | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Review</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>Review</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseReview(Review object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Comment</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>Comment</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseComment(Comment object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Item</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>Item</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseItem(Item object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Location</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>Location</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseLocation(Location 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 caseUser(User object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Task 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>Task Reference</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseTaskReference(TaskReference object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Review State</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>Review State</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseReviewState(ReviewState object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Review Group</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>Review Group</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseReviewGroup(ReviewGroup object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Comment 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>Comment Type</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseCommentType(CommentType object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Topic</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>Topic</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseTopic(Topic object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Review 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>Review Component</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseReviewComponent(ReviewComponent object) { | |
return null; | |
} | |
/** | |
* Returns the result of interpreting the object as an instance of '<em>Sub Model 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 interpreting the object as an instance of '<em>Sub Model Root</em>'. | |
* @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) | |
* @generated | |
*/ | |
public T caseSubModelRoot(SubModelRoot 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; | |
} | |
} //ModelSwitch |