PortInstanceImpl.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. /**
  2. */
  3. package ua.ansymo.hintco.impl;
  4. import java.lang.reflect.InvocationTargetException;
  5. import org.eclipse.emf.common.notify.Notification;
  6. import org.eclipse.emf.common.notify.NotificationChain;
  7. import org.eclipse.emf.common.util.BasicEList;
  8. import org.eclipse.emf.common.util.EList;
  9. import org.eclipse.emf.ecore.EClass;
  10. import org.eclipse.emf.ecore.InternalEObject;
  11. import org.eclipse.emf.ecore.impl.ENotificationImpl;
  12. import org.eclipse.emf.ecore.util.EcoreUtil;
  13. import ua.ansymo.hintco.DecompositionPortAdaptation;
  14. import ua.ansymo.hintco.HintcoPackage;
  15. import ua.ansymo.hintco.IDed;
  16. import ua.ansymo.hintco.PortAdaptation;
  17. import ua.ansymo.hintco.PortInstance;
  18. import ua.ansymo.hintco.UnitInstance;
  19. /**
  20. * <!-- begin-user-doc -->
  21. * An implementation of the model object '<em><b>Port Instance</b></em>'.
  22. * <!-- end-user-doc -->
  23. * <p>
  24. * The following features are implemented:
  25. * </p>
  26. * <ul>
  27. * <li>{@link ua.ansymo.hintco.impl.PortInstanceImpl#getIdentifier <em>Identifier</em>}</li>
  28. * <li>{@link ua.ansymo.hintco.impl.PortInstanceImpl#getUnit <em>Unit</em>}</li>
  29. * <li>{@link ua.ansymo.hintco.impl.PortInstanceImpl#getAdaptation <em>Adaptation</em>}</li>
  30. * </ul>
  31. *
  32. * @generated
  33. */
  34. public abstract class PortInstanceImpl extends PrecendenceNodeImpl implements PortInstance {
  35. /**
  36. * The default value of the '{@link #getIdentifier() <em>Identifier</em>}' attribute.
  37. * <!-- begin-user-doc -->
  38. * <!-- end-user-doc -->
  39. * @see #getIdentifier()
  40. * @generated
  41. * @ordered
  42. */
  43. protected static final String IDENTIFIER_EDEFAULT = null;
  44. /**
  45. * The cached value of the '{@link #getIdentifier() <em>Identifier</em>}' attribute.
  46. * <!-- begin-user-doc -->
  47. * <!-- end-user-doc -->
  48. * @see #getIdentifier()
  49. * @generated
  50. * @ordered
  51. */
  52. protected String identifier = IDENTIFIER_EDEFAULT;
  53. /**
  54. * The cached value of the '{@link #getAdaptation() <em>Adaptation</em>}' containment reference.
  55. * <!-- begin-user-doc -->
  56. * <!-- end-user-doc -->
  57. * @see #getAdaptation()
  58. * @generated
  59. * @ordered
  60. */
  61. protected PortAdaptation adaptation;
  62. /**
  63. * <!-- begin-user-doc -->
  64. * <!-- end-user-doc -->
  65. * @generated
  66. */
  67. protected PortInstanceImpl() {
  68. super();
  69. }
  70. /**
  71. * <!-- begin-user-doc -->
  72. * <!-- end-user-doc -->
  73. * @generated
  74. */
  75. @Override
  76. protected EClass eStaticClass() {
  77. return HintcoPackage.Literals.PORT_INSTANCE;
  78. }
  79. /**
  80. * <!-- begin-user-doc -->
  81. * <!-- end-user-doc -->
  82. * @generated
  83. */
  84. public String getIdentifier() {
  85. return identifier;
  86. }
  87. /**
  88. * <!-- begin-user-doc -->
  89. * <!-- end-user-doc -->
  90. * @generated
  91. */
  92. public void setIdentifier(String newIdentifier) {
  93. String oldIdentifier = identifier;
  94. identifier = newIdentifier;
  95. if (eNotificationRequired())
  96. eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__IDENTIFIER, oldIdentifier, identifier));
  97. }
  98. /**
  99. * <!-- begin-user-doc -->
  100. * <!-- end-user-doc -->
  101. * @generated
  102. */
  103. public UnitInstance getUnit() {
  104. if (eContainerFeatureID() != HintcoPackage.PORT_INSTANCE__UNIT) return null;
  105. return (UnitInstance)eContainer();
  106. }
  107. /**
  108. * <!-- begin-user-doc -->
  109. * <!-- end-user-doc -->
  110. * @generated
  111. */
  112. public UnitInstance basicGetUnit() {
  113. if (eContainerFeatureID() != HintcoPackage.PORT_INSTANCE__UNIT) return null;
  114. return (UnitInstance)eInternalContainer();
  115. }
  116. /**
  117. * <!-- begin-user-doc -->
  118. * <!-- end-user-doc -->
  119. * @generated
  120. */
  121. public NotificationChain basicSetUnit(UnitInstance newUnit, NotificationChain msgs) {
  122. msgs = eBasicSetContainer((InternalEObject)newUnit, HintcoPackage.PORT_INSTANCE__UNIT, msgs);
  123. return msgs;
  124. }
  125. /**
  126. * <!-- begin-user-doc -->
  127. * <!-- end-user-doc -->
  128. * @generated
  129. */
  130. public void setUnit(UnitInstance newUnit) {
  131. if (newUnit != eInternalContainer() || (eContainerFeatureID() != HintcoPackage.PORT_INSTANCE__UNIT && newUnit != null)) {
  132. if (EcoreUtil.isAncestor(this, newUnit))
  133. throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
  134. NotificationChain msgs = null;
  135. if (eInternalContainer() != null)
  136. msgs = eBasicRemoveFromContainer(msgs);
  137. if (newUnit != null)
  138. msgs = ((InternalEObject)newUnit).eInverseAdd(this, HintcoPackage.UNIT_INSTANCE__PORTS, UnitInstance.class, msgs);
  139. msgs = basicSetUnit(newUnit, msgs);
  140. if (msgs != null) msgs.dispatch();
  141. }
  142. else if (eNotificationRequired())
  143. eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__UNIT, newUnit, newUnit));
  144. }
  145. /**
  146. * <!-- begin-user-doc -->
  147. * <!-- end-user-doc -->
  148. * @generated
  149. */
  150. public PortAdaptation getAdaptation() {
  151. return adaptation;
  152. }
  153. /**
  154. * <!-- begin-user-doc -->
  155. * <!-- end-user-doc -->
  156. * @generated
  157. */
  158. public NotificationChain basicSetAdaptation(PortAdaptation newAdaptation, NotificationChain msgs) {
  159. PortAdaptation oldAdaptation = adaptation;
  160. adaptation = newAdaptation;
  161. if (eNotificationRequired()) {
  162. ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__ADAPTATION, oldAdaptation, newAdaptation);
  163. if (msgs == null) msgs = notification; else msgs.add(notification);
  164. }
  165. return msgs;
  166. }
  167. /**
  168. * <!-- begin-user-doc -->
  169. * <!-- end-user-doc -->
  170. * @generated
  171. */
  172. public void setAdaptation(PortAdaptation newAdaptation) {
  173. if (newAdaptation != adaptation) {
  174. NotificationChain msgs = null;
  175. if (adaptation != null)
  176. msgs = ((InternalEObject)adaptation).eInverseRemove(this, HintcoPackage.PORT_ADAPTATION__PORT, PortAdaptation.class, msgs);
  177. if (newAdaptation != null)
  178. msgs = ((InternalEObject)newAdaptation).eInverseAdd(this, HintcoPackage.PORT_ADAPTATION__PORT, PortAdaptation.class, msgs);
  179. msgs = basicSetAdaptation(newAdaptation, msgs);
  180. if (msgs != null) msgs.dispatch();
  181. }
  182. else if (eNotificationRequired())
  183. eNotify(new ENotificationImpl(this, Notification.SET, HintcoPackage.PORT_INSTANCE__ADAPTATION, newAdaptation, newAdaptation));
  184. }
  185. /**
  186. * <!-- begin-user-doc -->
  187. * <!-- end-user-doc -->
  188. * @generated
  189. */
  190. public EList<PortAdaptation> selectedAdaptations() {
  191. PortAdaptation _adaptation = this.getAdaptation();
  192. boolean _tripleEquals = (_adaptation == null);
  193. if (_tripleEquals) {
  194. return new BasicEList<PortAdaptation>(java.util.Collections.<PortAdaptation>unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.<PortAdaptation>newArrayList()));
  195. }
  196. boolean _isSelected = this.getAdaptation().isSelected();
  197. if (_isSelected) {
  198. PortAdaptation _adaptation_1 = this.getAdaptation();
  199. if ((_adaptation_1 instanceof DecompositionPortAdaptation)) {
  200. PortAdaptation _adaptation_2 = this.getAdaptation();
  201. return ((DecompositionPortAdaptation) _adaptation_2).selectedAdaptations();
  202. }
  203. PortAdaptation _adaptation_3 = this.getAdaptation();
  204. return new BasicEList<PortAdaptation>(java.util.Collections.<PortAdaptation>unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.<PortAdaptation>newArrayList(_adaptation_3)));
  205. }
  206. return new BasicEList<PortAdaptation>(java.util.Collections.<PortAdaptation>unmodifiableList(org.eclipse.xtext.xbase.lib.CollectionLiterals.<PortAdaptation>newArrayList()));
  207. }
  208. /**
  209. * <!-- begin-user-doc -->
  210. * <!-- end-user-doc -->
  211. * @generated
  212. */
  213. public boolean isInput() {
  214. return false;
  215. }
  216. /**
  217. * <!-- begin-user-doc -->
  218. * <!-- end-user-doc -->
  219. * @generated
  220. */
  221. public boolean getsValueFrom(final PortInstance p) {
  222. return false;
  223. }
  224. /**
  225. * <!-- begin-user-doc -->
  226. * <!-- end-user-doc -->
  227. * @generated
  228. */
  229. public String toString() {
  230. String _string = this.getUnit().toString();
  231. String _plus = (_string + ".");
  232. String _identifier = this.getIdentifier();
  233. return (_plus + _identifier);
  234. }
  235. /**
  236. * <!-- begin-user-doc -->
  237. * <!-- end-user-doc -->
  238. * @generated
  239. */
  240. @Override
  241. public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
  242. switch (featureID) {
  243. case HintcoPackage.PORT_INSTANCE__UNIT:
  244. if (eInternalContainer() != null)
  245. msgs = eBasicRemoveFromContainer(msgs);
  246. return basicSetUnit((UnitInstance)otherEnd, msgs);
  247. case HintcoPackage.PORT_INSTANCE__ADAPTATION:
  248. if (adaptation != null)
  249. msgs = ((InternalEObject)adaptation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - HintcoPackage.PORT_INSTANCE__ADAPTATION, null, msgs);
  250. return basicSetAdaptation((PortAdaptation)otherEnd, msgs);
  251. }
  252. return super.eInverseAdd(otherEnd, featureID, msgs);
  253. }
  254. /**
  255. * <!-- begin-user-doc -->
  256. * <!-- end-user-doc -->
  257. * @generated
  258. */
  259. @Override
  260. public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
  261. switch (featureID) {
  262. case HintcoPackage.PORT_INSTANCE__UNIT:
  263. return basicSetUnit(null, msgs);
  264. case HintcoPackage.PORT_INSTANCE__ADAPTATION:
  265. return basicSetAdaptation(null, msgs);
  266. }
  267. return super.eInverseRemove(otherEnd, featureID, msgs);
  268. }
  269. /**
  270. * <!-- begin-user-doc -->
  271. * <!-- end-user-doc -->
  272. * @generated
  273. */
  274. @Override
  275. public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
  276. switch (eContainerFeatureID()) {
  277. case HintcoPackage.PORT_INSTANCE__UNIT:
  278. return eInternalContainer().eInverseRemove(this, HintcoPackage.UNIT_INSTANCE__PORTS, UnitInstance.class, msgs);
  279. }
  280. return super.eBasicRemoveFromContainerFeature(msgs);
  281. }
  282. /**
  283. * <!-- begin-user-doc -->
  284. * <!-- end-user-doc -->
  285. * @generated
  286. */
  287. @Override
  288. public Object eGet(int featureID, boolean resolve, boolean coreType) {
  289. switch (featureID) {
  290. case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
  291. return getIdentifier();
  292. case HintcoPackage.PORT_INSTANCE__UNIT:
  293. if (resolve) return getUnit();
  294. return basicGetUnit();
  295. case HintcoPackage.PORT_INSTANCE__ADAPTATION:
  296. return getAdaptation();
  297. }
  298. return super.eGet(featureID, resolve, coreType);
  299. }
  300. /**
  301. * <!-- begin-user-doc -->
  302. * <!-- end-user-doc -->
  303. * @generated
  304. */
  305. @Override
  306. public void eSet(int featureID, Object newValue) {
  307. switch (featureID) {
  308. case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
  309. setIdentifier((String)newValue);
  310. return;
  311. case HintcoPackage.PORT_INSTANCE__UNIT:
  312. setUnit((UnitInstance)newValue);
  313. return;
  314. case HintcoPackage.PORT_INSTANCE__ADAPTATION:
  315. setAdaptation((PortAdaptation)newValue);
  316. return;
  317. }
  318. super.eSet(featureID, newValue);
  319. }
  320. /**
  321. * <!-- begin-user-doc -->
  322. * <!-- end-user-doc -->
  323. * @generated
  324. */
  325. @Override
  326. public void eUnset(int featureID) {
  327. switch (featureID) {
  328. case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
  329. setIdentifier(IDENTIFIER_EDEFAULT);
  330. return;
  331. case HintcoPackage.PORT_INSTANCE__UNIT:
  332. setUnit((UnitInstance)null);
  333. return;
  334. case HintcoPackage.PORT_INSTANCE__ADAPTATION:
  335. setAdaptation((PortAdaptation)null);
  336. return;
  337. }
  338. super.eUnset(featureID);
  339. }
  340. /**
  341. * <!-- begin-user-doc -->
  342. * <!-- end-user-doc -->
  343. * @generated
  344. */
  345. @Override
  346. public boolean eIsSet(int featureID) {
  347. switch (featureID) {
  348. case HintcoPackage.PORT_INSTANCE__IDENTIFIER:
  349. return IDENTIFIER_EDEFAULT == null ? identifier != null : !IDENTIFIER_EDEFAULT.equals(identifier);
  350. case HintcoPackage.PORT_INSTANCE__UNIT:
  351. return basicGetUnit() != null;
  352. case HintcoPackage.PORT_INSTANCE__ADAPTATION:
  353. return adaptation != null;
  354. }
  355. return super.eIsSet(featureID);
  356. }
  357. /**
  358. * <!-- begin-user-doc -->
  359. * <!-- end-user-doc -->
  360. * @generated
  361. */
  362. @Override
  363. public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) {
  364. if (baseClass == IDed.class) {
  365. switch (derivedFeatureID) {
  366. case HintcoPackage.PORT_INSTANCE__IDENTIFIER: return HintcoPackage.IDED__IDENTIFIER;
  367. default: return -1;
  368. }
  369. }
  370. return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass);
  371. }
  372. /**
  373. * <!-- begin-user-doc -->
  374. * <!-- end-user-doc -->
  375. * @generated
  376. */
  377. @Override
  378. public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) {
  379. if (baseClass == IDed.class) {
  380. switch (baseFeatureID) {
  381. case HintcoPackage.IDED__IDENTIFIER: return HintcoPackage.PORT_INSTANCE__IDENTIFIER;
  382. default: return -1;
  383. }
  384. }
  385. return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass);
  386. }
  387. /**
  388. * <!-- begin-user-doc -->
  389. * <!-- end-user-doc -->
  390. * @generated
  391. */
  392. @Override
  393. public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
  394. switch (operationID) {
  395. case HintcoPackage.PORT_INSTANCE___SELECTED_ADAPTATIONS:
  396. return selectedAdaptations();
  397. case HintcoPackage.PORT_INSTANCE___IS_INPUT:
  398. return isInput();
  399. case HintcoPackage.PORT_INSTANCE___GETS_VALUE_FROM__PORTINSTANCE:
  400. return getsValueFrom((PortInstance)arguments.get(0));
  401. case HintcoPackage.PORT_INSTANCE___TO_STRING:
  402. return toString();
  403. }
  404. return super.eInvoke(operationID, arguments);
  405. }
  406. } //PortInstanceImpl