| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package de.uka.ipd.sdq.probespec.impl; |
| 8 | |
| 9 | import de.uka.ipd.sdq.identifier.impl.IdentifierImpl; |
| 10 | |
| 11 | import de.uka.ipd.sdq.probespec.Probe; |
| 12 | import de.uka.ipd.sdq.probespec.ProbeSet; |
| 13 | import de.uka.ipd.sdq.probespec.ProbeSetPosition; |
| 14 | import de.uka.ipd.sdq.probespec.probespecPackage; |
| 15 | |
| 16 | import java.util.Collection; |
| 17 | |
| 18 | import org.eclipse.emf.common.notify.Notification; |
| 19 | import org.eclipse.emf.common.notify.NotificationChain; |
| 20 | |
| 21 | import org.eclipse.emf.common.util.EList; |
| 22 | |
| 23 | import org.eclipse.emf.ecore.EClass; |
| 24 | import org.eclipse.emf.ecore.EObject; |
| 25 | import org.eclipse.emf.ecore.InternalEObject; |
| 26 | |
| 27 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 28 | |
| 29 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 30 | import org.eclipse.emf.ecore.util.InternalEList; |
| 31 | |
| 32 | /** |
| 33 | * <!-- begin-user-doc --> |
| 34 | * An implementation of the model object '<em><b>Probe Set</b></em>'. |
| 35 | * <!-- end-user-doc --> |
| 36 | * <p> |
| 37 | * The following features are implemented: |
| 38 | * <ul> |
| 39 | * <li>{@link de.uka.ipd.sdq.probespec.impl.ProbeSetImpl#getProbes <em>Probes</em>}</li> |
| 40 | * <li>{@link de.uka.ipd.sdq.probespec.impl.ProbeSetImpl#getPosition <em>Position</em>}</li> |
| 41 | * <li>{@link de.uka.ipd.sdq.probespec.impl.ProbeSetImpl#getAnnotatedElement <em>Annotated Element</em>}</li> |
| 42 | * </ul> |
| 43 | * </p> |
| 44 | * |
| 45 | * @generated |
| 46 | */ |
| 47 | public class ProbeSetImpl extends IdentifierImpl implements ProbeSet { |
| 48 | /** |
| 49 | * The cached value of the '{@link #getProbes() <em>Probes</em>}' containment reference list. |
| 50 | * <!-- begin-user-doc --> |
| 51 | * <!-- end-user-doc --> |
| 52 | * @see #getProbes() |
| 53 | * @generated |
| 54 | * @ordered |
| 55 | */ |
| 56 | protected EList<Probe> probes; |
| 57 | |
| 58 | /** |
| 59 | * The default value of the '{@link #getPosition() <em>Position</em>}' attribute. |
| 60 | * <!-- begin-user-doc --> |
| 61 | * <!-- end-user-doc --> |
| 62 | * @see #getPosition() |
| 63 | * @generated |
| 64 | * @ordered |
| 65 | */ |
| 66 | protected static final ProbeSetPosition POSITION_EDEFAULT = ProbeSetPosition.BEFORE; |
| 67 | |
| 68 | /** |
| 69 | * The cached value of the '{@link #getPosition() <em>Position</em>}' attribute. |
| 70 | * <!-- begin-user-doc --> |
| 71 | * <!-- end-user-doc --> |
| 72 | * @see #getPosition() |
| 73 | * @generated |
| 74 | * @ordered |
| 75 | */ |
| 76 | protected ProbeSetPosition position = POSITION_EDEFAULT; |
| 77 | |
| 78 | /** |
| 79 | * The cached value of the '{@link #getAnnotatedElement() <em>Annotated Element</em>}' reference. |
| 80 | * <!-- begin-user-doc --> |
| 81 | * <!-- end-user-doc --> |
| 82 | * @see #getAnnotatedElement() |
| 83 | * @generated |
| 84 | * @ordered |
| 85 | */ |
| 86 | protected EObject annotatedElement; |
| 87 | |
| 88 | /** |
| 89 | * <!-- begin-user-doc --> |
| 90 | * <!-- end-user-doc --> |
| 91 | * @generated |
| 92 | */ |
| 93 | protected ProbeSetImpl() { |
| 94 | super(); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * <!-- begin-user-doc --> |
| 99 | * <!-- end-user-doc --> |
| 100 | * @generated |
| 101 | */ |
| 102 | @Override |
| 103 | protected EClass eStaticClass() { |
| 104 | return probespecPackage.Literals.PROBE_SET; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * <!-- begin-user-doc --> |
| 109 | * <!-- end-user-doc --> |
| 110 | * @generated |
| 111 | */ |
| 112 | public EList<Probe> getProbes() { |
| 113 | if (probes == null) { |
| 114 | probes = new EObjectContainmentEList<Probe>(Probe.class, this, probespecPackage.PROBE_SET__PROBES); |
| 115 | } |
| 116 | return probes; |
| 117 | } |
| 118 | |
| 119 | /** |
| 120 | * <!-- begin-user-doc --> |
| 121 | * <!-- end-user-doc --> |
| 122 | * @generated |
| 123 | */ |
| 124 | public ProbeSetPosition getPosition() { |
| 125 | return position; |
| 126 | } |
| 127 | |
| 128 | /** |
| 129 | * <!-- begin-user-doc --> |
| 130 | * <!-- end-user-doc --> |
| 131 | * @generated |
| 132 | */ |
| 133 | public void setPosition(ProbeSetPosition newPosition) { |
| 134 | ProbeSetPosition oldPosition = position; |
| 135 | position = newPosition == null ? POSITION_EDEFAULT : newPosition; |
| 136 | if (eNotificationRequired()) |
| 137 | eNotify(new ENotificationImpl(this, Notification.SET, probespecPackage.PROBE_SET__POSITION, oldPosition, position)); |
| 138 | } |
| 139 | |
| 140 | /** |
| 141 | * <!-- begin-user-doc --> |
| 142 | * <!-- end-user-doc --> |
| 143 | * @generated |
| 144 | */ |
| 145 | public EObject getAnnotatedElement() { |
| 146 | if (annotatedElement != null && annotatedElement.eIsProxy()) { |
| 147 | InternalEObject oldAnnotatedElement = (InternalEObject)annotatedElement; |
| 148 | annotatedElement = eResolveProxy(oldAnnotatedElement); |
| 149 | if (annotatedElement != oldAnnotatedElement) { |
| 150 | if (eNotificationRequired()) |
| 151 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, probespecPackage.PROBE_SET__ANNOTATED_ELEMENT, oldAnnotatedElement, annotatedElement)); |
| 152 | } |
| 153 | } |
| 154 | return annotatedElement; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * <!-- begin-user-doc --> |
| 159 | * <!-- end-user-doc --> |
| 160 | * @generated |
| 161 | */ |
| 162 | public EObject basicGetAnnotatedElement() { |
| 163 | return annotatedElement; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * <!-- begin-user-doc --> |
| 168 | * <!-- end-user-doc --> |
| 169 | * @generated |
| 170 | */ |
| 171 | public void setAnnotatedElement(EObject newAnnotatedElement) { |
| 172 | EObject oldAnnotatedElement = annotatedElement; |
| 173 | annotatedElement = newAnnotatedElement; |
| 174 | if (eNotificationRequired()) |
| 175 | eNotify(new ENotificationImpl(this, Notification.SET, probespecPackage.PROBE_SET__ANNOTATED_ELEMENT, oldAnnotatedElement, annotatedElement)); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * <!-- begin-user-doc --> |
| 180 | * <!-- end-user-doc --> |
| 181 | * @generated |
| 182 | */ |
| 183 | @Override |
| 184 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 185 | switch (featureID) { |
| 186 | case probespecPackage.PROBE_SET__PROBES: |
| 187 | return ((InternalEList<?>)getProbes()).basicRemove(otherEnd, msgs); |
| 188 | } |
| 189 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 190 | } |
| 191 | |
| 192 | /** |
| 193 | * <!-- begin-user-doc --> |
| 194 | * <!-- end-user-doc --> |
| 195 | * @generated |
| 196 | */ |
| 197 | @Override |
| 198 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 199 | switch (featureID) { |
| 200 | case probespecPackage.PROBE_SET__PROBES: |
| 201 | return getProbes(); |
| 202 | case probespecPackage.PROBE_SET__POSITION: |
| 203 | return getPosition(); |
| 204 | case probespecPackage.PROBE_SET__ANNOTATED_ELEMENT: |
| 205 | if (resolve) return getAnnotatedElement(); |
| 206 | return basicGetAnnotatedElement(); |
| 207 | } |
| 208 | return super.eGet(featureID, resolve, coreType); |
| 209 | } |
| 210 | |
| 211 | /** |
| 212 | * <!-- begin-user-doc --> |
| 213 | * <!-- end-user-doc --> |
| 214 | * @generated |
| 215 | */ |
| 216 | @SuppressWarnings("unchecked") |
| 217 | @Override |
| 218 | public void eSet(int featureID, Object newValue) { |
| 219 | switch (featureID) { |
| 220 | case probespecPackage.PROBE_SET__PROBES: |
| 221 | getProbes().clear(); |
| 222 | getProbes().addAll((Collection<? extends Probe>)newValue); |
| 223 | return; |
| 224 | case probespecPackage.PROBE_SET__POSITION: |
| 225 | setPosition((ProbeSetPosition)newValue); |
| 226 | return; |
| 227 | case probespecPackage.PROBE_SET__ANNOTATED_ELEMENT: |
| 228 | setAnnotatedElement((EObject)newValue); |
| 229 | return; |
| 230 | } |
| 231 | super.eSet(featureID, newValue); |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * <!-- begin-user-doc --> |
| 236 | * <!-- end-user-doc --> |
| 237 | * @generated |
| 238 | */ |
| 239 | @Override |
| 240 | public void eUnset(int featureID) { |
| 241 | switch (featureID) { |
| 242 | case probespecPackage.PROBE_SET__PROBES: |
| 243 | getProbes().clear(); |
| 244 | return; |
| 245 | case probespecPackage.PROBE_SET__POSITION: |
| 246 | setPosition(POSITION_EDEFAULT); |
| 247 | return; |
| 248 | case probespecPackage.PROBE_SET__ANNOTATED_ELEMENT: |
| 249 | setAnnotatedElement((EObject)null); |
| 250 | return; |
| 251 | } |
| 252 | super.eUnset(featureID); |
| 253 | } |
| 254 | |
| 255 | /** |
| 256 | * <!-- begin-user-doc --> |
| 257 | * <!-- end-user-doc --> |
| 258 | * @generated |
| 259 | */ |
| 260 | @Override |
| 261 | public boolean eIsSet(int featureID) { |
| 262 | switch (featureID) { |
| 263 | case probespecPackage.PROBE_SET__PROBES: |
| 264 | return probes != null && !probes.isEmpty(); |
| 265 | case probespecPackage.PROBE_SET__POSITION: |
| 266 | return position != POSITION_EDEFAULT; |
| 267 | case probespecPackage.PROBE_SET__ANNOTATED_ELEMENT: |
| 268 | return annotatedElement != null; |
| 269 | } |
| 270 | return super.eIsSet(featureID); |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * <!-- begin-user-doc --> |
| 275 | * <!-- end-user-doc --> |
| 276 | * @generated |
| 277 | */ |
| 278 | @Override |
| 279 | public String toString() { |
| 280 | if (eIsProxy()) return super.toString(); |
| 281 | |
| 282 | StringBuffer result = new StringBuffer(super.toString()); |
| 283 | result.append(" (position: "); |
| 284 | result.append(position); |
| 285 | result.append(')'); |
| 286 | return result.toString(); |
| 287 | } |
| 288 | |
| 289 | } //ProbeSetImpl |