/restructuration/org.eclipse.emf.compare.mpatch.test.eachonce/src/eachonce/util/EachonceSwitch.java

https://github.com/zenobios/emf.compare · Java · 137 lines · 46 code · 11 blank · 80 comment · 8 complexity · d98a84a0f842b5c1224f5ea332f7237b MD5 · raw file

  1. /*******************************************************************************
  2. * Copyright (c) 2010, 2011 Technical University of Denmark.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors:
  9. * Patrick Koenemann, DTU Informatics - initial API and implementation
  10. *
  11. * $Id: EachonceSwitch.java,v 1.1 2010/09/10 15:40:34 cbrun Exp $
  12. *******************************************************************************/
  13. package eachonce.util;
  14. import java.util.List;
  15. import org.eclipse.emf.ecore.EClass;
  16. import org.eclipse.emf.ecore.EObject;
  17. import eachonce.EachoncePackage;
  18. import eachonce.Entity;
  19. /**
  20. * <!-- begin-user-doc -->
  21. * The <b>Switch</b> for the model's inheritance hierarchy.
  22. * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
  23. * to invoke the <code>caseXXX</code> method for each class of the model,
  24. * starting with the actual class of the object
  25. * and proceeding up the inheritance hierarchy
  26. * until a non-null result is returned,
  27. * which is the result of the switch.
  28. * <!-- end-user-doc -->
  29. * @see eachonce.EachoncePackage
  30. * @generated
  31. */
  32. public class EachonceSwitch<T> {
  33. /**
  34. * The cached model package
  35. * <!-- begin-user-doc -->
  36. * <!-- end-user-doc -->
  37. * @generated
  38. */
  39. protected static EachoncePackage modelPackage;
  40. /**
  41. * Creates an instance of the switch.
  42. * <!-- begin-user-doc -->
  43. * <!-- end-user-doc -->
  44. * @generated
  45. */
  46. public EachonceSwitch() {
  47. if (modelPackage == null) {
  48. modelPackage = EachoncePackage.eINSTANCE;
  49. }
  50. }
  51. /**
  52. * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
  53. * <!-- begin-user-doc -->
  54. * <!-- end-user-doc -->
  55. * @return the first non-null result returned by a <code>caseXXX</code> call.
  56. * @generated
  57. */
  58. public T doSwitch(EObject theEObject) {
  59. return doSwitch(theEObject.eClass(), theEObject);
  60. }
  61. /**
  62. * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
  63. * <!-- begin-user-doc -->
  64. * <!-- end-user-doc -->
  65. * @return the first non-null result returned by a <code>caseXXX</code> call.
  66. * @generated
  67. */
  68. protected T doSwitch(EClass theEClass, EObject theEObject) {
  69. if (theEClass.eContainer() == modelPackage) {
  70. return doSwitch(theEClass.getClassifierID(), theEObject);
  71. }
  72. else {
  73. List<EClass> eSuperTypes = theEClass.getESuperTypes();
  74. return
  75. eSuperTypes.isEmpty() ?
  76. defaultCase(theEObject) :
  77. doSwitch(eSuperTypes.get(0), theEObject);
  78. }
  79. }
  80. /**
  81. * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
  82. * <!-- begin-user-doc -->
  83. * <!-- end-user-doc -->
  84. * @return the first non-null result returned by a <code>caseXXX</code> call.
  85. * @generated
  86. */
  87. protected T doSwitch(int classifierID, EObject theEObject) {
  88. switch (classifierID) {
  89. case EachoncePackage.ENTITY: {
  90. Entity entity = (Entity)theEObject;
  91. T result = caseEntity(entity);
  92. if (result == null) result = defaultCase(theEObject);
  93. return result;
  94. }
  95. default: return defaultCase(theEObject);
  96. }
  97. }
  98. /**
  99. * Returns the result of interpreting the object as an instance of '<em>Entity</em>'.
  100. * <!-- begin-user-doc -->
  101. * This implementation returns null;
  102. * returning a non-null result will terminate the switch.
  103. * <!-- end-user-doc -->
  104. * @param object the target of the switch.
  105. * @return the result of interpreting the object as an instance of '<em>Entity</em>'.
  106. * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
  107. * @generated
  108. */
  109. public T caseEntity(Entity object) {
  110. return null;
  111. }
  112. /**
  113. * Returns the result of interpreting the object as an instance of '<em>EObject</em>'.
  114. * <!-- begin-user-doc -->
  115. * This implementation returns null;
  116. * returning a non-null result will terminate the switch, but this is the last case anyway.
  117. * <!-- end-user-doc -->
  118. * @param object the target of the switch.
  119. * @return the result of interpreting the object as an instance of '<em>EObject</em>'.
  120. * @see #doSwitch(org.eclipse.emf.ecore.EObject)
  121. * @generated
  122. */
  123. public T defaultCase(EObject object) {
  124. return null;
  125. }
  126. } //EachonceSwitch