| 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 java.util.Collection; |
| 13 | |
| 14 | import org.eclipse.emf.common.notify.Notification; |
| 15 | import org.eclipse.emf.common.notify.NotificationChain; |
| 16 | |
| 17 | import org.eclipse.emf.common.util.EList; |
| 18 | |
| 19 | import org.eclipse.emf.ecore.EClass; |
| 20 | import org.eclipse.emf.ecore.InternalEObject; |
| 21 | |
| 22 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 23 | import org.eclipse.emf.ecore.impl.EObjectImpl; |
| 24 | |
| 25 | import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; |
| 26 | import org.eclipse.emf.ecore.util.InternalEList; |
| 27 | |
| 28 | /** |
| 29 | * <!-- begin-user-doc --> |
| 30 | * An implementation of the model object '<em><b>Active Resouce</b></em>'. |
| 31 | * <!-- end-user-doc --> |
| 32 | * <p> |
| 33 | * The following features are implemented: |
| 34 | * <ul> |
| 35 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.ActiveResouceImpl#getWaitingDemands <em>Waiting Demands</em>}</li> |
| 36 | * <li>{@link de.uka.ipd.sdq.simucomframework.simucomstatus.impl.ActiveResouceImpl#getId <em>Id</em>}</li> |
| 37 | * </ul> |
| 38 | * </p> |
| 39 | * |
| 40 | * @generated |
| 41 | */ |
| 42 | public class ActiveResouceImpl extends EObjectImpl implements ActiveResouce { |
| 43 | /** |
| 44 | * The cached value of the '{@link #getWaitingDemands() <em>Waiting Demands</em>}' reference list. |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @see #getWaitingDemands() |
| 48 | * @generated |
| 49 | * @ordered |
| 50 | */ |
| 51 | protected EList<WaitForDemand> waitingDemands; |
| 52 | |
| 53 | /** |
| 54 | * The default value of the '{@link #getId() <em>Id</em>}' attribute. |
| 55 | * <!-- begin-user-doc --> |
| 56 | * <!-- end-user-doc --> |
| 57 | * @see #getId() |
| 58 | * @generated |
| 59 | * @ordered |
| 60 | */ |
| 61 | protected static final String ID_EDEFAULT = null; |
| 62 | |
| 63 | /** |
| 64 | * The cached value of the '{@link #getId() <em>Id</em>}' attribute. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @see #getId() |
| 68 | * @generated |
| 69 | * @ordered |
| 70 | */ |
| 71 | protected String id = ID_EDEFAULT; |
| 72 | |
| 73 | /** |
| 74 | * <!-- begin-user-doc --> |
| 75 | * <!-- end-user-doc --> |
| 76 | * @generated |
| 77 | */ |
| 78 | protected ActiveResouceImpl() { |
| 79 | super(); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * <!-- begin-user-doc --> |
| 84 | * <!-- end-user-doc --> |
| 85 | * @generated |
| 86 | */ |
| 87 | @Override |
| 88 | protected EClass eStaticClass() { |
| 89 | return SimucomstatusPackage.Literals.ACTIVE_RESOUCE; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | public EList<WaitForDemand> getWaitingDemands() { |
| 98 | if (waitingDemands == null) { |
| 99 | waitingDemands = new EObjectWithInverseResolvingEList<WaitForDemand>(WaitForDemand.class, this, SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS, SimucomstatusPackage.WAIT_FOR_DEMAND__RESOURCE); |
| 100 | } |
| 101 | return waitingDemands; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * <!-- begin-user-doc --> |
| 106 | * <!-- end-user-doc --> |
| 107 | * @generated |
| 108 | */ |
| 109 | public String getId() { |
| 110 | return id; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * <!-- begin-user-doc --> |
| 115 | * <!-- end-user-doc --> |
| 116 | * @generated |
| 117 | */ |
| 118 | public void setId(String newId) { |
| 119 | String oldId = id; |
| 120 | id = newId; |
| 121 | if (eNotificationRequired()) |
| 122 | eNotify(new ENotificationImpl(this, Notification.SET, SimucomstatusPackage.ACTIVE_RESOUCE__ID, oldId, id)); |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * <!-- begin-user-doc --> |
| 127 | * <!-- end-user-doc --> |
| 128 | * @generated |
| 129 | */ |
| 130 | @SuppressWarnings("unchecked") |
| 131 | @Override |
| 132 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 133 | switch (featureID) { |
| 134 | case SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS: |
| 135 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getWaitingDemands()).basicAdd(otherEnd, msgs); |
| 136 | } |
| 137 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * <!-- begin-user-doc --> |
| 142 | * <!-- end-user-doc --> |
| 143 | * @generated |
| 144 | */ |
| 145 | @Override |
| 146 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 147 | switch (featureID) { |
| 148 | case SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS: |
| 149 | return ((InternalEList<?>)getWaitingDemands()).basicRemove(otherEnd, msgs); |
| 150 | } |
| 151 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 152 | } |
| 153 | |
| 154 | /** |
| 155 | * <!-- begin-user-doc --> |
| 156 | * <!-- end-user-doc --> |
| 157 | * @generated |
| 158 | */ |
| 159 | @Override |
| 160 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 161 | switch (featureID) { |
| 162 | case SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS: |
| 163 | return getWaitingDemands(); |
| 164 | case SimucomstatusPackage.ACTIVE_RESOUCE__ID: |
| 165 | return getId(); |
| 166 | } |
| 167 | return super.eGet(featureID, resolve, coreType); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * <!-- begin-user-doc --> |
| 172 | * <!-- end-user-doc --> |
| 173 | * @generated |
| 174 | */ |
| 175 | @SuppressWarnings("unchecked") |
| 176 | @Override |
| 177 | public void eSet(int featureID, Object newValue) { |
| 178 | switch (featureID) { |
| 179 | case SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS: |
| 180 | getWaitingDemands().clear(); |
| 181 | getWaitingDemands().addAll((Collection<? extends WaitForDemand>)newValue); |
| 182 | return; |
| 183 | case SimucomstatusPackage.ACTIVE_RESOUCE__ID: |
| 184 | setId((String)newValue); |
| 185 | return; |
| 186 | } |
| 187 | super.eSet(featureID, newValue); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * <!-- begin-user-doc --> |
| 192 | * <!-- end-user-doc --> |
| 193 | * @generated |
| 194 | */ |
| 195 | @Override |
| 196 | public void eUnset(int featureID) { |
| 197 | switch (featureID) { |
| 198 | case SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS: |
| 199 | getWaitingDemands().clear(); |
| 200 | return; |
| 201 | case SimucomstatusPackage.ACTIVE_RESOUCE__ID: |
| 202 | setId(ID_EDEFAULT); |
| 203 | return; |
| 204 | } |
| 205 | super.eUnset(featureID); |
| 206 | } |
| 207 | |
| 208 | /** |
| 209 | * <!-- begin-user-doc --> |
| 210 | * <!-- end-user-doc --> |
| 211 | * @generated |
| 212 | */ |
| 213 | @Override |
| 214 | public boolean eIsSet(int featureID) { |
| 215 | switch (featureID) { |
| 216 | case SimucomstatusPackage.ACTIVE_RESOUCE__WAITING_DEMANDS: |
| 217 | return waitingDemands != null && !waitingDemands.isEmpty(); |
| 218 | case SimucomstatusPackage.ACTIVE_RESOUCE__ID: |
| 219 | return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id); |
| 220 | } |
| 221 | return super.eIsSet(featureID); |
| 222 | } |
| 223 | |
| 224 | /** |
| 225 | * <!-- begin-user-doc --> |
| 226 | * <!-- end-user-doc --> |
| 227 | * @generated |
| 228 | */ |
| 229 | @Override |
| 230 | public String toString() { |
| 231 | if (eIsProxy()) return super.toString(); |
| 232 | |
| 233 | StringBuffer result = new StringBuffer(super.toString()); |
| 234 | result.append(" (id: "); |
| 235 | result.append(id); |
| 236 | result.append(')'); |
| 237 | return result.toString(); |
| 238 | } |
| 239 | |
| 240 | } //ActiveResouceImpl |