001 /**
002 * <copyright>
003 * </copyright>
004 *
005 * $Id$
006 */
007 package com.hammurapi.flow.impl;
008
009 import com.hammurapi.config.Named;
010 import java.util.Collection;
011
012 import org.eclipse.emf.common.notify.Notification;
013 import org.eclipse.emf.common.notify.NotificationChain;
014 import org.eclipse.emf.common.util.EList;
015 import org.eclipse.emf.ecore.EClass;
016 import org.eclipse.emf.ecore.InternalEObject;
017 import org.eclipse.emf.ecore.impl.ENotificationImpl;
018 import org.eclipse.emf.ecore.util.EObjectContainmentEList;
019 import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
020 import org.eclipse.emf.ecore.util.EcoreUtil;
021 import org.eclipse.emf.ecore.util.InternalEList;
022
023 import com.hammurapi.config.impl.NamedObjectDefinitionImpl;
024 import com.hammurapi.flow.Flow;
025 import com.hammurapi.flow.FlowPackage;
026 import com.hammurapi.flow.Node;
027 import com.hammurapi.flow.Pin;
028
029 /**
030 * <!-- begin-user-doc -->
031 * An implementation of the model object '<em><b>Node</b></em>'.
032 * <!-- end-user-doc -->
033 * <p>
034 * The following features are implemented:
035 * <ul>
036 * <li>{@link com.hammurapi.flow.impl.NodeImpl#getFlow <em>Flow</em>}</li>
037 * <li>{@link com.hammurapi.flow.impl.NodeImpl#getViewConfig <em>View Config</em>}</li>
038 * <li>{@link com.hammurapi.flow.impl.NodeImpl#getPin <em>Pin</em>}</li>
039 * </ul>
040 * </p>
041 *
042 * @generated
043 */
044 public class NodeImpl extends NamedObjectDefinitionImpl implements Node {
045 /**
046 * The cached value of the '{@link #getViewConfig() <em>View Config</em>}' containment reference list.
047 * <!-- begin-user-doc -->
048 * <!-- end-user-doc -->
049 * @see #getViewConfig()
050 * @generated
051 * @ordered
052 */
053 protected EList<Named> viewConfig;
054 /**
055 * The cached value of the '{@link #getPin() <em>Pin</em>}' containment reference list.
056 * <!-- begin-user-doc -->
057 * <!-- end-user-doc -->
058 * @see #getPin()
059 * @generated
060 * @ordered
061 */
062 protected EList<Pin> pin;
063
064 /**
065 * <!-- begin-user-doc -->
066 * <!-- end-user-doc -->
067 * @generated
068 */
069 protected NodeImpl() {
070 super();
071 }
072
073 /**
074 * <!-- begin-user-doc -->
075 * <!-- end-user-doc -->
076 * @generated
077 */
078 @Override
079 protected EClass eStaticClass() {
080 return FlowPackage.Literals.NODE;
081 }
082
083 /**
084 * <!-- begin-user-doc -->
085 * <!-- end-user-doc -->
086 * @generated
087 */
088 public Flow getFlow() {
089 if (eContainerFeatureID() != FlowPackage.NODE__FLOW) return null;
090 return (Flow)eContainer();
091 }
092
093 /**
094 * <!-- begin-user-doc -->
095 * <!-- end-user-doc -->
096 * @generated
097 */
098 public NotificationChain basicSetFlow(Flow newFlow, NotificationChain msgs) {
099 msgs = eBasicSetContainer((InternalEObject)newFlow, FlowPackage.NODE__FLOW, msgs);
100 return msgs;
101 }
102
103 /**
104 * <!-- begin-user-doc -->
105 * <!-- end-user-doc -->
106 * @generated
107 */
108 public void setFlow(Flow newFlow) {
109 if (newFlow != eInternalContainer() || (eContainerFeatureID() != FlowPackage.NODE__FLOW && newFlow != null)) {
110 if (EcoreUtil.isAncestor(this, newFlow))
111 throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
112 NotificationChain msgs = null;
113 if (eInternalContainer() != null)
114 msgs = eBasicRemoveFromContainer(msgs);
115 if (newFlow != null)
116 msgs = ((InternalEObject)newFlow).eInverseAdd(this, FlowPackage.FLOW__FLOW_ELEMENT, Flow.class, msgs);
117 msgs = basicSetFlow(newFlow, msgs);
118 if (msgs != null) msgs.dispatch();
119 }
120 else if (eNotificationRequired())
121 eNotify(new ENotificationImpl(this, Notification.SET, FlowPackage.NODE__FLOW, newFlow, newFlow));
122 }
123
124 /**
125 * <!-- begin-user-doc -->
126 * <!-- end-user-doc -->
127 * @generated
128 */
129 public EList<Named> getViewConfig() {
130 if (viewConfig == null) {
131 viewConfig = new EObjectContainmentEList<Named>(Named.class, this, FlowPackage.NODE__VIEW_CONFIG);
132 }
133 return viewConfig;
134 }
135
136 /**
137 * <!-- begin-user-doc -->
138 * <!-- end-user-doc -->
139 * @generated
140 */
141 public EList<Pin> getPin() {
142 if (pin == null) {
143 pin = new EObjectContainmentWithInverseEList<Pin>(Pin.class, this, FlowPackage.NODE__PIN, FlowPackage.PIN__NODE);
144 }
145 return pin;
146 }
147
148 /**
149 * <!-- begin-user-doc -->
150 * <!-- end-user-doc -->
151 * @generated
152 */
153 @SuppressWarnings("unchecked")
154 @Override
155 public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
156 switch (featureID) {
157 case FlowPackage.NODE__FLOW:
158 if (eInternalContainer() != null)
159 msgs = eBasicRemoveFromContainer(msgs);
160 return basicSetFlow((Flow)otherEnd, msgs);
161 case FlowPackage.NODE__PIN:
162 return ((InternalEList<InternalEObject>)(InternalEList<?>)getPin()).basicAdd(otherEnd, msgs);
163 }
164 return super.eInverseAdd(otherEnd, featureID, msgs);
165 }
166
167 /**
168 * <!-- begin-user-doc -->
169 * <!-- end-user-doc -->
170 * @generated
171 */
172 @Override
173 public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
174 switch (featureID) {
175 case FlowPackage.NODE__FLOW:
176 return basicSetFlow(null, msgs);
177 case FlowPackage.NODE__VIEW_CONFIG:
178 return ((InternalEList<?>)getViewConfig()).basicRemove(otherEnd, msgs);
179 case FlowPackage.NODE__PIN:
180 return ((InternalEList<?>)getPin()).basicRemove(otherEnd, msgs);
181 }
182 return super.eInverseRemove(otherEnd, featureID, msgs);
183 }
184
185 /**
186 * <!-- begin-user-doc -->
187 * <!-- end-user-doc -->
188 * @generated
189 */
190 @Override
191 public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
192 switch (eContainerFeatureID()) {
193 case FlowPackage.NODE__FLOW:
194 return eInternalContainer().eInverseRemove(this, FlowPackage.FLOW__FLOW_ELEMENT, Flow.class, msgs);
195 }
196 return super.eBasicRemoveFromContainerFeature(msgs);
197 }
198
199 /**
200 * <!-- begin-user-doc -->
201 * <!-- end-user-doc -->
202 * @generated
203 */
204 @Override
205 public Object eGet(int featureID, boolean resolve, boolean coreType) {
206 switch (featureID) {
207 case FlowPackage.NODE__FLOW:
208 return getFlow();
209 case FlowPackage.NODE__VIEW_CONFIG:
210 return getViewConfig();
211 case FlowPackage.NODE__PIN:
212 return getPin();
213 }
214 return super.eGet(featureID, resolve, coreType);
215 }
216
217 /**
218 * <!-- begin-user-doc -->
219 * <!-- end-user-doc -->
220 * @generated
221 */
222 @SuppressWarnings("unchecked")
223 @Override
224 public void eSet(int featureID, Object newValue) {
225 switch (featureID) {
226 case FlowPackage.NODE__FLOW:
227 setFlow((Flow)newValue);
228 return;
229 case FlowPackage.NODE__VIEW_CONFIG:
230 getViewConfig().clear();
231 getViewConfig().addAll((Collection<? extends Named>)newValue);
232 return;
233 case FlowPackage.NODE__PIN:
234 getPin().clear();
235 getPin().addAll((Collection<? extends Pin>)newValue);
236 return;
237 }
238 super.eSet(featureID, newValue);
239 }
240
241 /**
242 * <!-- begin-user-doc -->
243 * <!-- end-user-doc -->
244 * @generated
245 */
246 @Override
247 public void eUnset(int featureID) {
248 switch (featureID) {
249 case FlowPackage.NODE__FLOW:
250 setFlow((Flow)null);
251 return;
252 case FlowPackage.NODE__VIEW_CONFIG:
253 getViewConfig().clear();
254 return;
255 case FlowPackage.NODE__PIN:
256 getPin().clear();
257 return;
258 }
259 super.eUnset(featureID);
260 }
261
262 /**
263 * <!-- begin-user-doc -->
264 * <!-- end-user-doc -->
265 * @generated
266 */
267 @Override
268 public boolean eIsSet(int featureID) {
269 switch (featureID) {
270 case FlowPackage.NODE__FLOW:
271 return getFlow() != null;
272 case FlowPackage.NODE__VIEW_CONFIG:
273 return viewConfig != null && !viewConfig.isEmpty();
274 case FlowPackage.NODE__PIN:
275 return pin != null && !pin.isEmpty();
276 }
277 return super.eIsSet(featureID);
278 }
279
280 } //NodeImpl