| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.core.composition.impl; |
| 7 | |
| 8 | import org.eclipse.emf.common.notify.Notification; |
| 9 | import org.eclipse.emf.common.notify.NotificationChain; |
| 10 | import org.eclipse.emf.common.util.EList; |
| 11 | import org.eclipse.emf.ecore.EClass; |
| 12 | import org.eclipse.emf.ecore.InternalEObject; |
| 13 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 14 | import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; |
| 15 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 16 | |
| 17 | import org.eclipse.emf.ecore.util.InternalEList; |
| 18 | import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure; |
| 19 | import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage; |
| 20 | import de.uka.ipd.sdq.pcm.core.composition.EventChannel; |
| 21 | import de.uka.ipd.sdq.pcm.core.composition.EventChannelSinkConnector; |
| 22 | import de.uka.ipd.sdq.pcm.core.composition.EventChannelSourceConnector; |
| 23 | import de.uka.ipd.sdq.pcm.core.entity.impl.EntityImpl; |
| 24 | import de.uka.ipd.sdq.pcm.repository.EventGroup; |
| 25 | import java.util.Collection; |
| 26 | |
| 27 | /** |
| 28 | * <!-- begin-user-doc --> |
| 29 | * An implementation of the model object '<em><b>Event Channel</b></em>'. |
| 30 | * <!-- end-user-doc --> |
| 31 | * <p> |
| 32 | * The following features are implemented: |
| 33 | * <ul> |
| 34 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.EventChannelImpl#getEventGroup__EventChannel <em>Event Group Event Channel</em>}</li> |
| 35 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.EventChannelImpl#getEventChannelSourceConnector__EventChannel <em>Event Channel Source Connector Event Channel</em>}</li> |
| 36 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.EventChannelImpl#getEventChannelSinkConnector__EventChannel <em>Event Channel Sink Connector Event Channel</em>}</li> |
| 37 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.EventChannelImpl#getParentStructure__EventChannel <em>Parent Structure Event Channel</em>}</li> |
| 38 | * </ul> |
| 39 | * </p> |
| 40 | * |
| 41 | * @generated |
| 42 | */ |
| 43 | public class EventChannelImpl extends EntityImpl implements EventChannel { |
| 44 | /** |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @generated |
| 48 | */ |
| 49 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 50 | |
| 51 | /** |
| 52 | * The cached value of the '{@link #getEventGroup__EventChannel() <em>Event Group Event Channel</em>}' reference. |
| 53 | * <!-- begin-user-doc --> |
| 54 | * <!-- end-user-doc --> |
| 55 | * @see #getEventGroup__EventChannel() |
| 56 | * @generated |
| 57 | * @ordered |
| 58 | */ |
| 59 | protected EventGroup eventGroup__EventChannel; |
| 60 | |
| 61 | /** |
| 62 | * The cached value of the '{@link #getEventChannelSourceConnector__EventChannel() <em>Event Channel Source Connector Event Channel</em>}' reference list. |
| 63 | * <!-- begin-user-doc --> |
| 64 | * <!-- end-user-doc --> |
| 65 | * @see #getEventChannelSourceConnector__EventChannel() |
| 66 | * @generated |
| 67 | * @ordered |
| 68 | */ |
| 69 | protected EList<EventChannelSourceConnector> eventChannelSourceConnector__EventChannel; |
| 70 | |
| 71 | /** |
| 72 | * The cached value of the '{@link #getEventChannelSinkConnector__EventChannel() <em>Event Channel Sink Connector Event Channel</em>}' reference list. |
| 73 | * <!-- begin-user-doc --> |
| 74 | * <!-- end-user-doc --> |
| 75 | * @see #getEventChannelSinkConnector__EventChannel() |
| 76 | * @generated |
| 77 | * @ordered |
| 78 | */ |
| 79 | protected EList<EventChannelSinkConnector> eventChannelSinkConnector__EventChannel; |
| 80 | |
| 81 | /** |
| 82 | * <!-- begin-user-doc --> |
| 83 | * <!-- end-user-doc --> |
| 84 | * @generated |
| 85 | */ |
| 86 | protected EventChannelImpl() { |
| 87 | super(); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * <!-- begin-user-doc --> |
| 92 | * <!-- end-user-doc --> |
| 93 | * @generated |
| 94 | */ |
| 95 | @Override |
| 96 | protected EClass eStaticClass() { |
| 97 | return CompositionPackage.Literals.EVENT_CHANNEL; |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * <!-- begin-user-doc --> |
| 102 | * <!-- end-user-doc --> |
| 103 | * @generated |
| 104 | */ |
| 105 | public EventGroup getEventGroup__EventChannel() { |
| 106 | if (eventGroup__EventChannel != null && eventGroup__EventChannel.eIsProxy()) { |
| 107 | InternalEObject oldEventGroup__EventChannel = (InternalEObject)eventGroup__EventChannel; |
| 108 | eventGroup__EventChannel = (EventGroup)eResolveProxy(oldEventGroup__EventChannel); |
| 109 | if (eventGroup__EventChannel != oldEventGroup__EventChannel) { |
| 110 | if (eNotificationRequired()) |
| 111 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, CompositionPackage.EVENT_CHANNEL__EVENT_GROUP_EVENT_CHANNEL, oldEventGroup__EventChannel, eventGroup__EventChannel)); |
| 112 | } |
| 113 | } |
| 114 | return eventGroup__EventChannel; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * <!-- begin-user-doc --> |
| 119 | * <!-- end-user-doc --> |
| 120 | * @generated |
| 121 | */ |
| 122 | public EventGroup basicGetEventGroup__EventChannel() { |
| 123 | return eventGroup__EventChannel; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | public void setEventGroup__EventChannel(EventGroup newEventGroup__EventChannel) { |
| 132 | EventGroup oldEventGroup__EventChannel = eventGroup__EventChannel; |
| 133 | eventGroup__EventChannel = newEventGroup__EventChannel; |
| 134 | if (eNotificationRequired()) |
| 135 | eNotify(new ENotificationImpl(this, Notification.SET, CompositionPackage.EVENT_CHANNEL__EVENT_GROUP_EVENT_CHANNEL, oldEventGroup__EventChannel, eventGroup__EventChannel)); |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * <!-- begin-user-doc --> |
| 140 | * <!-- end-user-doc --> |
| 141 | * @generated |
| 142 | */ |
| 143 | public EList<EventChannelSourceConnector> getEventChannelSourceConnector__EventChannel() { |
| 144 | if (eventChannelSourceConnector__EventChannel == null) { |
| 145 | eventChannelSourceConnector__EventChannel = new EObjectWithInverseResolvingEList<EventChannelSourceConnector>(EventChannelSourceConnector.class, this, CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL, CompositionPackage.EVENT_CHANNEL_SOURCE_CONNECTOR__EVENT_CHANNEL_EVENT_CHANNEL_SOURCE_CONNECTOR); |
| 146 | } |
| 147 | return eventChannelSourceConnector__EventChannel; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * <!-- begin-user-doc --> |
| 152 | * <!-- end-user-doc --> |
| 153 | * @generated |
| 154 | */ |
| 155 | public EList<EventChannelSinkConnector> getEventChannelSinkConnector__EventChannel() { |
| 156 | if (eventChannelSinkConnector__EventChannel == null) { |
| 157 | eventChannelSinkConnector__EventChannel = new EObjectWithInverseResolvingEList<EventChannelSinkConnector>(EventChannelSinkConnector.class, this, CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL, CompositionPackage.EVENT_CHANNEL_SINK_CONNECTOR__EVENT_CHANNEL_EVENT_CHANNEL_SINK_CONNECTOR); |
| 158 | } |
| 159 | return eventChannelSinkConnector__EventChannel; |
| 160 | } |
| 161 | |
| 162 | /** |
| 163 | * <!-- begin-user-doc --> |
| 164 | * <!-- end-user-doc --> |
| 165 | * @generated |
| 166 | */ |
| 167 | public ComposedStructure getParentStructure__EventChannel() { |
| 168 | if (eContainerFeatureID() != CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL) return null; |
| 169 | return (ComposedStructure)eContainer(); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * <!-- begin-user-doc --> |
| 174 | * <!-- end-user-doc --> |
| 175 | * @generated |
| 176 | */ |
| 177 | public NotificationChain basicSetParentStructure__EventChannel(ComposedStructure newParentStructure__EventChannel, NotificationChain msgs) { |
| 178 | msgs = eBasicSetContainer((InternalEObject)newParentStructure__EventChannel, CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL, msgs); |
| 179 | return msgs; |
| 180 | } |
| 181 | |
| 182 | /** |
| 183 | * <!-- begin-user-doc --> |
| 184 | * <!-- end-user-doc --> |
| 185 | * @generated |
| 186 | */ |
| 187 | public void setParentStructure__EventChannel(ComposedStructure newParentStructure__EventChannel) { |
| 188 | if (newParentStructure__EventChannel != eInternalContainer() || (eContainerFeatureID() != CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL && newParentStructure__EventChannel != null)) { |
| 189 | if (EcoreUtil.isAncestor(this, newParentStructure__EventChannel)) |
| 190 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 191 | NotificationChain msgs = null; |
| 192 | if (eInternalContainer() != null) |
| 193 | msgs = eBasicRemoveFromContainer(msgs); |
| 194 | if (newParentStructure__EventChannel != null) |
| 195 | msgs = ((InternalEObject)newParentStructure__EventChannel).eInverseAdd(this, CompositionPackage.COMPOSED_STRUCTURE__EVENT_CHANNEL_COMPOSED_STRUCTURE, ComposedStructure.class, msgs); |
| 196 | msgs = basicSetParentStructure__EventChannel(newParentStructure__EventChannel, msgs); |
| 197 | if (msgs != null) msgs.dispatch(); |
| 198 | } |
| 199 | else if (eNotificationRequired()) |
| 200 | eNotify(new ENotificationImpl(this, Notification.SET, CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL, newParentStructure__EventChannel, newParentStructure__EventChannel)); |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * <!-- begin-user-doc --> |
| 205 | * <!-- end-user-doc --> |
| 206 | * @generated |
| 207 | */ |
| 208 | @SuppressWarnings("unchecked") |
| 209 | @Override |
| 210 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 211 | switch (featureID) { |
| 212 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL: |
| 213 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getEventChannelSourceConnector__EventChannel()).basicAdd(otherEnd, msgs); |
| 214 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL: |
| 215 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getEventChannelSinkConnector__EventChannel()).basicAdd(otherEnd, msgs); |
| 216 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 217 | if (eInternalContainer() != null) |
| 218 | msgs = eBasicRemoveFromContainer(msgs); |
| 219 | return basicSetParentStructure__EventChannel((ComposedStructure)otherEnd, msgs); |
| 220 | } |
| 221 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * <!-- begin-user-doc --> |
| 226 | * <!-- end-user-doc --> |
| 227 | * @generated |
| 228 | */ |
| 229 | @Override |
| 230 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 231 | switch (featureID) { |
| 232 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL: |
| 233 | return ((InternalEList<?>)getEventChannelSourceConnector__EventChannel()).basicRemove(otherEnd, msgs); |
| 234 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL: |
| 235 | return ((InternalEList<?>)getEventChannelSinkConnector__EventChannel()).basicRemove(otherEnd, msgs); |
| 236 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 237 | return basicSetParentStructure__EventChannel(null, msgs); |
| 238 | } |
| 239 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * <!-- begin-user-doc --> |
| 244 | * <!-- end-user-doc --> |
| 245 | * @generated |
| 246 | */ |
| 247 | @Override |
| 248 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 249 | switch (eContainerFeatureID()) { |
| 250 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 251 | return eInternalContainer().eInverseRemove(this, CompositionPackage.COMPOSED_STRUCTURE__EVENT_CHANNEL_COMPOSED_STRUCTURE, ComposedStructure.class, msgs); |
| 252 | } |
| 253 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * <!-- begin-user-doc --> |
| 258 | * <!-- end-user-doc --> |
| 259 | * @generated |
| 260 | */ |
| 261 | @Override |
| 262 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 263 | switch (featureID) { |
| 264 | case CompositionPackage.EVENT_CHANNEL__EVENT_GROUP_EVENT_CHANNEL: |
| 265 | if (resolve) return getEventGroup__EventChannel(); |
| 266 | return basicGetEventGroup__EventChannel(); |
| 267 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL: |
| 268 | return getEventChannelSourceConnector__EventChannel(); |
| 269 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL: |
| 270 | return getEventChannelSinkConnector__EventChannel(); |
| 271 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 272 | return getParentStructure__EventChannel(); |
| 273 | } |
| 274 | return super.eGet(featureID, resolve, coreType); |
| 275 | } |
| 276 | |
| 277 | /** |
| 278 | * <!-- begin-user-doc --> |
| 279 | * <!-- end-user-doc --> |
| 280 | * @generated |
| 281 | */ |
| 282 | @SuppressWarnings("unchecked") |
| 283 | @Override |
| 284 | public void eSet(int featureID, Object newValue) { |
| 285 | switch (featureID) { |
| 286 | case CompositionPackage.EVENT_CHANNEL__EVENT_GROUP_EVENT_CHANNEL: |
| 287 | setEventGroup__EventChannel((EventGroup)newValue); |
| 288 | return; |
| 289 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL: |
| 290 | getEventChannelSourceConnector__EventChannel().clear(); |
| 291 | getEventChannelSourceConnector__EventChannel().addAll((Collection<? extends EventChannelSourceConnector>)newValue); |
| 292 | return; |
| 293 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL: |
| 294 | getEventChannelSinkConnector__EventChannel().clear(); |
| 295 | getEventChannelSinkConnector__EventChannel().addAll((Collection<? extends EventChannelSinkConnector>)newValue); |
| 296 | return; |
| 297 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 298 | setParentStructure__EventChannel((ComposedStructure)newValue); |
| 299 | return; |
| 300 | } |
| 301 | super.eSet(featureID, newValue); |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * <!-- begin-user-doc --> |
| 306 | * <!-- end-user-doc --> |
| 307 | * @generated |
| 308 | */ |
| 309 | @Override |
| 310 | public void eUnset(int featureID) { |
| 311 | switch (featureID) { |
| 312 | case CompositionPackage.EVENT_CHANNEL__EVENT_GROUP_EVENT_CHANNEL: |
| 313 | setEventGroup__EventChannel((EventGroup)null); |
| 314 | return; |
| 315 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL: |
| 316 | getEventChannelSourceConnector__EventChannel().clear(); |
| 317 | return; |
| 318 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL: |
| 319 | getEventChannelSinkConnector__EventChannel().clear(); |
| 320 | return; |
| 321 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 322 | setParentStructure__EventChannel((ComposedStructure)null); |
| 323 | return; |
| 324 | } |
| 325 | super.eUnset(featureID); |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * <!-- begin-user-doc --> |
| 330 | * <!-- end-user-doc --> |
| 331 | * @generated |
| 332 | */ |
| 333 | @Override |
| 334 | public boolean eIsSet(int featureID) { |
| 335 | switch (featureID) { |
| 336 | case CompositionPackage.EVENT_CHANNEL__EVENT_GROUP_EVENT_CHANNEL: |
| 337 | return eventGroup__EventChannel != null; |
| 338 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SOURCE_CONNECTOR_EVENT_CHANNEL: |
| 339 | return eventChannelSourceConnector__EventChannel != null && !eventChannelSourceConnector__EventChannel.isEmpty(); |
| 340 | case CompositionPackage.EVENT_CHANNEL__EVENT_CHANNEL_SINK_CONNECTOR_EVENT_CHANNEL: |
| 341 | return eventChannelSinkConnector__EventChannel != null && !eventChannelSinkConnector__EventChannel.isEmpty(); |
| 342 | case CompositionPackage.EVENT_CHANNEL__PARENT_STRUCTURE_EVENT_CHANNEL: |
| 343 | return getParentStructure__EventChannel() != null; |
| 344 | } |
| 345 | return super.eIsSet(featureID); |
| 346 | } |
| 347 | |
| 348 | } //EventChannelImpl |