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