| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.units.impl; |
| 8 | |
| 9 | import de.uka.ipd.sdq.units.Unit; |
| 10 | import de.uka.ipd.sdq.units.UnitPower; |
| 11 | import de.uka.ipd.sdq.units.UnitsPackage; |
| 12 | |
| 13 | import org.eclipse.emf.common.notify.Notification; |
| 14 | import org.eclipse.emf.common.notify.NotificationChain; |
| 15 | |
| 16 | import org.eclipse.emf.ecore.EClass; |
| 17 | import org.eclipse.emf.ecore.InternalEObject; |
| 18 | |
| 19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 20 | |
| 21 | /** |
| 22 | * <!-- begin-user-doc --> |
| 23 | * An implementation of the model object '<em><b>Unit Power</b></em>'. |
| 24 | * <!-- end-user-doc --> |
| 25 | * <p> |
| 26 | * The following features are implemented: |
| 27 | * <ul> |
| 28 | * <li>{@link de.uka.ipd.sdq.units.impl.UnitPowerImpl#getUnit <em>Unit</em>}</li> |
| 29 | * <li>{@link de.uka.ipd.sdq.units.impl.UnitPowerImpl#getExponent <em>Exponent</em>}</li> |
| 30 | * </ul> |
| 31 | * </p> |
| 32 | * |
| 33 | * @generated |
| 34 | */ |
| 35 | public class UnitPowerImpl extends UnitImpl implements UnitPower { |
| 36 | /** |
| 37 | * <!-- begin-user-doc --> |
| 38 | * <!-- end-user-doc --> |
| 39 | * @generated |
| 40 | */ |
| 41 | public static final String copyright = "Copyright 2007-2009, SDQ, IPD, U Karlsruhe"; |
| 42 | |
| 43 | /** |
| 44 | * The cached value of the '{@link #getUnit() <em>Unit</em>}' containment reference. |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @see #getUnit() |
| 48 | * @generated |
| 49 | * @ordered |
| 50 | */ |
| 51 | protected Unit unit; |
| 52 | |
| 53 | /** |
| 54 | * The default value of the '{@link #getExponent() <em>Exponent</em>}' attribute. |
| 55 | * <!-- begin-user-doc --> |
| 56 | * <!-- end-user-doc --> |
| 57 | * @see #getExponent() |
| 58 | * @generated |
| 59 | * @ordered |
| 60 | */ |
| 61 | protected static final int EXPONENT_EDEFAULT = 0; |
| 62 | |
| 63 | /** |
| 64 | * The cached value of the '{@link #getExponent() <em>Exponent</em>}' attribute. |
| 65 | * <!-- begin-user-doc --> |
| 66 | * <!-- end-user-doc --> |
| 67 | * @see #getExponent() |
| 68 | * @generated |
| 69 | * @ordered |
| 70 | */ |
| 71 | protected int exponent = EXPONENT_EDEFAULT; |
| 72 | |
| 73 | /** |
| 74 | * <!-- begin-user-doc --> |
| 75 | * <!-- end-user-doc --> |
| 76 | * @generated |
| 77 | */ |
| 78 | protected UnitPowerImpl() { |
| 79 | super(); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * <!-- begin-user-doc --> |
| 84 | * <!-- end-user-doc --> |
| 85 | * @generated |
| 86 | */ |
| 87 | @Override |
| 88 | protected EClass eStaticClass() { |
| 89 | return UnitsPackage.Literals.UNIT_POWER; |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <!-- begin-user-doc --> |
| 94 | * <!-- end-user-doc --> |
| 95 | * @generated |
| 96 | */ |
| 97 | public Unit getUnit() { |
| 98 | return unit; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * <!-- begin-user-doc --> |
| 103 | * <!-- end-user-doc --> |
| 104 | * @generated |
| 105 | */ |
| 106 | public NotificationChain basicSetUnit(Unit newUnit, NotificationChain msgs) { |
| 107 | Unit oldUnit = unit; |
| 108 | unit = newUnit; |
| 109 | if (eNotificationRequired()) { |
| 110 | ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, UnitsPackage.UNIT_POWER__UNIT, oldUnit, newUnit); |
| 111 | if (msgs == null) msgs = notification; else msgs.add(notification); |
| 112 | } |
| 113 | return msgs; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * <!-- begin-user-doc --> |
| 118 | * <!-- end-user-doc --> |
| 119 | * @generated |
| 120 | */ |
| 121 | public void setUnit(Unit newUnit) { |
| 122 | if (newUnit != unit) { |
| 123 | NotificationChain msgs = null; |
| 124 | if (unit != null) |
| 125 | msgs = ((InternalEObject)unit).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - UnitsPackage.UNIT_POWER__UNIT, null, msgs); |
| 126 | if (newUnit != null) |
| 127 | msgs = ((InternalEObject)newUnit).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - UnitsPackage.UNIT_POWER__UNIT, null, msgs); |
| 128 | msgs = basicSetUnit(newUnit, msgs); |
| 129 | if (msgs != null) msgs.dispatch(); |
| 130 | } |
| 131 | else if (eNotificationRequired()) |
| 132 | eNotify(new ENotificationImpl(this, Notification.SET, UnitsPackage.UNIT_POWER__UNIT, newUnit, newUnit)); |
| 133 | } |
| 134 | |
| 135 | /** |
| 136 | * <!-- begin-user-doc --> |
| 137 | * <!-- end-user-doc --> |
| 138 | * @generated |
| 139 | */ |
| 140 | public int getExponent() { |
| 141 | return exponent; |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * <!-- begin-user-doc --> |
| 146 | * <!-- end-user-doc --> |
| 147 | * @generated |
| 148 | */ |
| 149 | public void setExponent(int newExponent) { |
| 150 | int oldExponent = exponent; |
| 151 | exponent = newExponent; |
| 152 | if (eNotificationRequired()) |
| 153 | eNotify(new ENotificationImpl(this, Notification.SET, UnitsPackage.UNIT_POWER__EXPONENT, oldExponent, exponent)); |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * <!-- begin-user-doc --> |
| 158 | * <!-- end-user-doc --> |
| 159 | * @generated |
| 160 | */ |
| 161 | @Override |
| 162 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 163 | switch (featureID) { |
| 164 | case UnitsPackage.UNIT_POWER__UNIT: |
| 165 | return basicSetUnit(null, msgs); |
| 166 | } |
| 167 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * <!-- begin-user-doc --> |
| 172 | * <!-- end-user-doc --> |
| 173 | * @generated |
| 174 | */ |
| 175 | @Override |
| 176 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 177 | switch (featureID) { |
| 178 | case UnitsPackage.UNIT_POWER__UNIT: |
| 179 | return getUnit(); |
| 180 | case UnitsPackage.UNIT_POWER__EXPONENT: |
| 181 | return getExponent(); |
| 182 | } |
| 183 | return super.eGet(featureID, resolve, coreType); |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * <!-- begin-user-doc --> |
| 188 | * <!-- end-user-doc --> |
| 189 | * @generated |
| 190 | */ |
| 191 | @Override |
| 192 | public void eSet(int featureID, Object newValue) { |
| 193 | switch (featureID) { |
| 194 | case UnitsPackage.UNIT_POWER__UNIT: |
| 195 | setUnit((Unit)newValue); |
| 196 | return; |
| 197 | case UnitsPackage.UNIT_POWER__EXPONENT: |
| 198 | setExponent((Integer)newValue); |
| 199 | return; |
| 200 | } |
| 201 | super.eSet(featureID, newValue); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * <!-- begin-user-doc --> |
| 206 | * <!-- end-user-doc --> |
| 207 | * @generated |
| 208 | */ |
| 209 | @Override |
| 210 | public void eUnset(int featureID) { |
| 211 | switch (featureID) { |
| 212 | case UnitsPackage.UNIT_POWER__UNIT: |
| 213 | setUnit((Unit)null); |
| 214 | return; |
| 215 | case UnitsPackage.UNIT_POWER__EXPONENT: |
| 216 | setExponent(EXPONENT_EDEFAULT); |
| 217 | return; |
| 218 | } |
| 219 | super.eUnset(featureID); |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * <!-- begin-user-doc --> |
| 224 | * <!-- end-user-doc --> |
| 225 | * @generated |
| 226 | */ |
| 227 | @Override |
| 228 | public boolean eIsSet(int featureID) { |
| 229 | switch (featureID) { |
| 230 | case UnitsPackage.UNIT_POWER__UNIT: |
| 231 | return unit != null; |
| 232 | case UnitsPackage.UNIT_POWER__EXPONENT: |
| 233 | return exponent != EXPONENT_EDEFAULT; |
| 234 | } |
| 235 | return super.eIsSet(featureID); |
| 236 | } |
| 237 | |
| 238 | /** |
| 239 | * <!-- begin-user-doc --> |
| 240 | * <!-- end-user-doc --> |
| 241 | * @generated |
| 242 | */ |
| 243 | @Override |
| 244 | public String toString() { |
| 245 | if (eIsProxy()) return super.toString(); |
| 246 | |
| 247 | StringBuffer result = new StringBuffer(super.toString()); |
| 248 | result.append(" (exponent: "); |
| 249 | result.append(exponent); |
| 250 | result.append(')'); |
| 251 | return result.toString(); |
| 252 | } |
| 253 | |
| 254 | } //UnitPowerImpl |