| 1 | /** |
| 2 | * Copyright 2008, sdq.ipd.uka.de, U KA |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.simucomframework.simucomstatus.impl; |
| 7 | |
| 8 | import de.uka.ipd.sdq.simucomframework.simucomstatus.ActiveResouce; |
| 9 | import de.uka.ipd.sdq.simucomframework.simucomstatus.SimucomstatusPackage; |
| 10 | import de.uka.ipd.sdq.simucomframework.simucomstatus.WaitForDemand; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.Notification; |
| 13 | import org.eclipse.emf.common.notify.NotificationChain; |
| 14 | |
| 15 | import org.eclipse.emf.ecore.EClass; |
| 16 | import org.eclipse.emf.ecore.InternalEObject; |
| 17 | |
| 18 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 19 | |
| 20 | /** |
| 21 | * <!-- begin-user-doc --> |
| 22 | * An implementation of the model object '<em><b>Wait For Demand</b></em>'. |
| 23 | * <!-- end-user-doc --> |
| 24 | * <p> |
| 25 | * The following features are implemented: |
| 26 | * <ul> |
| 27 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.WaitForDemandImpl#getDemand <em>Demand</em>}</li> |
| 28 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.WaitForDemandImpl#getResource <em>Resource</em>}</li> |
| 29 | * </ul> |
| 30 | * </p> |
| 31 | * |
| 32 | * @generated |
| 33 | */ |
| 34 | public class WaitForDemandImpl extends ActionImpl implements WaitForDemand { |
| 35 | /** |
| 36 | * The default value of the '{@link #getDemand() <em>Demand</em>}' attribute. |
| 37 | * <!-- begin-user-doc --> |
| 38 | * <!-- end-user-doc --> |
| 39 | * @see #getDemand() |
| 40 | * @generated |
| 41 | * @ordered |
| 42 | */ |
| 43 | protected static final double DEMAND_EDEFAULT = 0.0; |
| 44 | |
| 45 | /** |
| 46 | * The cached value of the '{@link #getDemand() <em>Demand</em>}' attribute. |
| 47 | * <!-- begin-user-doc --> |
| 48 | * <!-- end-user-doc --> |
| 49 | * @see #getDemand() |
| 50 | * @generated |
| 51 | * @ordered |
| 52 | */ |
| 53 | protected double demand = DEMAND_EDEFAULT; |
| 54 | |
| 55 | /** |
| 56 | * The cached value of the '{@link #getResource() <em>Resource</em>}' reference. |
| 57 | * <!-- begin-user-doc --> |
| 58 | * <!-- end-user-doc --> |
| 59 | * @see #getResource() |
| 60 | * @generated |
| 61 | * @ordered |
| 62 | */ |
| 63 | protected ActiveResouce resource; |
| 64 | |
| 65 | /** |
| 66 | * <!-- begin-user-doc --> |
| 67 | * <!-- end-user-doc --> |
| 68 | * @generated |
| 69 | */ |
| 70 | protected WaitForDemandImpl() { |
| 71 | super(); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * <!-- begin-user-doc --> |
| 76 | * <!-- end-user-doc --> |
| 77 | * @generated |
| 78 | */ |
| 79 | @Override |
| 80 | protected EClass eStaticClass() { |
| 81 | return SimucomstatusPackage.Literals.WAIT_FOR_DEMAND; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * <!-- begin-user-doc --> |
| 86 | * <!-- end-user-doc --> |
| 87 | * @generated |
| 88 | */ |
| 89 | public double getDemand() { |
| 90 | return demand; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * <!-- begin-user-doc --> |
| 95 | * <!-- end-user-doc --> |
| 96 | * @generated |
| 97 | */ |
| 98 | public void setDemand(double newDemand) { |
| 99 | double oldDemand = demand; |
| 100 | demand = newDemand; |
| 101 | if (eNotificationRequired()) |
| 102 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.WAIT_FOR_DEMAND__DEMAND, oldDemand, demand)); |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * <!-- begin-user-doc --> |
| 107 | * <!-- end-user-doc --> |
| 108 | * @generated |
| 109 | */ |
| 110 | public ActiveResouce getResource() { |
| 111 | if (resource != null && resource.eIsProxy()) { |
| 112 | InternalEObject oldResource = (InternalEObject)resource; |
| 113 | resource = (ActiveResouce)eResolveProxy(oldResource); |
| 114 | if (resource != oldResource) { |
| 115 | if (eNotificationRequired()) |
| 116 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE, oldResource, resource)); |
| 117 | } |
| 118 | } |
| 119 | return resource; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * <!-- begin-user-doc --> |
| 124 | * <!-- end-user-doc --> |
| 125 | * @generated |
| 126 | */ |
| 127 | public ActiveResouce basicGetResource() { |
| 128 | return resource; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | public NotificationChain basicSetResource(ActiveResouce newResource, NotificationChain msgs) { |
| 137 | ActiveResouce oldResource = resource; |
| 138 | resource = newResource; |
| 139 | if (eNotificationRequired()) { |
| 140 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE, oldResource, newResource); |
| 141 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 142 | } |
| 143 | return msgs; |
| 144 | } |
| 145 | |
| 146 | /** |
| 147 | * <!-- begin-user-doc --> |
| 148 | * <!-- end-user-doc --> |
| 149 | * @generated |
| 150 | */ |
| 151 | public void setResource(ActiveResouce newResource) { |
| 152 | if (newResource != resource) { |
| 153 | NotificationChain msgs = null; |
| 154 | if (resource != null) |
| 155 | msgs = ((InternalEObject)resource).eInverseRemove(this, SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS, ActiveResouce.class, msgs); |
| 156 | if (newResource != null) |
| 157 | msgs = ((InternalEObject)newResource).eInverseAdd(this, SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS, ActiveResouce.class, msgs); |
| 158 | msgs = basicSetResource(newResource, msgs); |
| 159 | if (msgs != null) msgs.dispatch(); |
| 160 | } |
| 161 | else if (eNotificationRequired()) |
| 162 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE, newResource, newResource)); |
| 163 | } |
| 164 | |
| 165 | /** |
| 166 | * <!-- begin-user-doc --> |
| 167 | * <!-- end-user-doc --> |
| 168 | * @generated |
| 169 | */ |
| 170 | @Override |
| 171 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 172 | switch (featureID) { |
| 173 | case SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE: |
| 174 | if (resource != null) |
| 175 | msgs = ((InternalEObject)resource).eInverseRemove(this, SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS, ActiveResouce.class, msgs); |
| 176 | return basicSetResource((ActiveResouce)otherEnd, msgs); |
| 177 | } |
| 178 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * <!-- begin-user-doc --> |
| 183 | * <!-- end-user-doc --> |
| 184 | * @generated |
| 185 | */ |
| 186 | @Override |
| 187 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 188 | switch (featureID) { |
| 189 | case SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE: |
| 190 | return basicSetResource(null, msgs); |
| 191 | } |
| 192 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * <!-- begin-user-doc --> |
| 197 | * <!-- end-user-doc --> |
| 198 | * @generated |
| 199 | */ |
| 200 | @Override |
| 201 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 202 | switch (featureID) { |
| 203 | case SimucomstatusPackage.WAIT_FOR_DEMAND__DEMAND: |
| 204 | return new Double(getDemand()); |
| 205 | case SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE: |
| 206 | if (resolve) return getResource(); |
| 207 | return basicGetResource(); |
| 208 | } |
| 209 | return super.eGet(featureID, resolve, coreType); |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * <!-- begin-user-doc --> |
| 214 | * <!-- end-user-doc --> |
| 215 | * @generated |
| 216 | */ |
| 217 | @Override |
| 218 | public void eSet(int featureID, Object newValue) { |
| 219 | switch (featureID) { |
| 220 | case SimucomstatusPackage.WAIT_FOR_DEMAND__DEMAND: |
| 221 | setDemand(((Double)newValue).doubleValue()); |
| 222 | return; |
| 223 | case SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE: |
| 224 | setResource((ActiveResouce)newValue); |
| 225 | return; |
| 226 | } |
| 227 | super.eSet(featureID, newValue); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * <!-- begin-user-doc --> |
| 232 | * <!-- end-user-doc --> |
| 233 | * @generated |
| 234 | */ |
| 235 | @Override |
| 236 | public void eUnset(int featureID) { |
| 237 | switch (featureID) { |
| 238 | case SimucomstatusPackage.WAIT_FOR_DEMAND__DEMAND: |
| 239 | setDemand(DEMAND_EDEFAULT); |
| 240 | return; |
| 241 | case SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE: |
| 242 | setResource((ActiveResouce)null); |
| 243 | return; |
| 244 | } |
| 245 | super.eUnset(featureID); |
| 246 | } |
| 247 | |
| 248 | /** |
| 249 | * <!-- begin-user-doc --> |
| 250 | * <!-- end-user-doc --> |
| 251 | * @generated |
| 252 | */ |
| 253 | @Override |
| 254 | public boolean eIsSet(int featureID) { |
| 255 | switch (featureID) { |
| 256 | case SimucomstatusPackage.WAIT_FOR_DEMAND__DEMAND: |
| 257 | return demand != DEMAND_EDEFAULT; |
| 258 | case SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE: |
| 259 | return resource != null; |
| 260 | } |
| 261 | return super.eIsSet(featureID); |
| 262 | } |
| 263 | |
| 264 | /** |
| 265 | * <!-- begin-user-doc --> |
| 266 | * <!-- end-user-doc --> |
| 267 | * @generated |
| 268 | */ |
| 269 | @Override |
| 270 | public String toString() { |
| 271 | if (eIsProxy()) return super.toString(); |
| 272 | |
| 273 | StringBuffer result = new StringBuffer(super.toString()); |
| 274 | result.append(" (demand: "); |
| 275 | result.append(demand); |
| 276 | result.append(')'); |
| 277 | return result.toString(); |
| 278 | } |
| 279 | |
| 280 | } //WaitForDemandImpl |