| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.repository.impl; |
| 7 | |
| 8 | import java.util.Collection; |
| 9 | import java.util.Map; |
| 10 | |
| 11 | import org.eclipse.emf.common.notify.Notification; |
| 12 | import org.eclipse.emf.common.notify.NotificationChain; |
| 13 | import org.eclipse.emf.common.util.BasicDiagnostic; |
| 14 | import org.eclipse.emf.common.util.Diagnostic; |
| 15 | import org.eclipse.emf.common.util.DiagnosticChain; |
| 16 | import org.eclipse.emf.common.util.EList; |
| 17 | import org.eclipse.emf.ecore.EClass; |
| 18 | import org.eclipse.emf.ecore.InternalEObject; |
| 19 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 20 | import org.eclipse.emf.ecore.plugin.EcorePlugin; |
| 21 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
| 22 | import org.eclipse.emf.ecore.util.EObjectValidator; |
| 23 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 24 | import org.eclipse.emf.ecore.util.InternalEList; |
| 25 | import org.eclipse.ocl.ParserException; |
| 26 | import org.eclipse.ocl.ecore.Constraint; |
| 27 | import org.eclipse.ocl.ecore.OCL; |
| 28 | |
| 29 | import de.uka.ipd.sdq.pcm.repository.DataType; |
| 30 | import de.uka.ipd.sdq.pcm.repository.OperationInterface; |
| 31 | import de.uka.ipd.sdq.pcm.repository.OperationSignature; |
| 32 | import de.uka.ipd.sdq.pcm.repository.Parameter; |
| 33 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
| 34 | import de.uka.ipd.sdq.pcm.repository.util.RepositoryValidator; |
| 35 | |
| 36 | /** |
| 37 | * <!-- begin-user-doc --> |
| 38 | * An implementation of the model object '<em><b>Operation Signature</b></em>'. |
| 39 | * <!-- end-user-doc --> |
| 40 | * <p> |
| 41 | * The following features are implemented: |
| 42 | * <ul> |
| 43 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.OperationSignatureImpl#getInterface__OperationSignature <em>Interface Operation Signature</em>}</li> |
| 44 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.OperationSignatureImpl#getParameters__OperationSignature <em>Parameters Operation Signature</em>}</li> |
| 45 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.OperationSignatureImpl#getReturnType__OperationSignature <em>Return Type Operation Signature</em>}</li> |
| 46 | * </ul> |
| 47 | * </p> |
| 48 | * |
| 49 | * @generated |
| 50 | */ |
| 51 | public class OperationSignatureImpl extends SignatureImpl implements OperationSignature { |
| 52 | /** |
| 53 | * <!-- begin-user-doc --> |
| 54 | * <!-- end-user-doc --> |
| 55 | * @generated |
| 56 | */ |
| 57 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 58 | |
| 59 | /** |
| 60 | * The cached value of the '{@link #getParameters__OperationSignature() <em>Parameters Operation Signature</em>}' containment reference list. |
| 61 | * <!-- begin-user-doc --> |
| 62 | * <!-- end-user-doc --> |
| 63 | * @see #getParameters__OperationSignature() |
| 64 | * @generated |
| 65 | * @ordered |
| 66 | */ |
| 67 | protected EList<Parameter> parameters__OperationSignature; |
| 68 | |
| 69 | /** |
| 70 | * The cached value of the '{@link #getReturnType__OperationSignature() <em>Return Type Operation Signature</em>}' reference. |
| 71 | * <!-- begin-user-doc --> |
| 72 | * <!-- end-user-doc --> |
| 73 | * @see #getReturnType__OperationSignature() |
| 74 | * @generated |
| 75 | * @ordered |
| 76 | */ |
| 77 | protected DataType returnType__OperationSignature; |
| 78 | |
| 79 | /** |
| 80 | * <!-- begin-user-doc --> |
| 81 | * <!-- end-user-doc --> |
| 82 | * @generated |
| 83 | */ |
| 84 | protected OperationSignatureImpl() { |
| 85 | super(); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * <!-- begin-user-doc --> |
| 90 | * <!-- end-user-doc --> |
| 91 | * @generated |
| 92 | */ |
| 93 | @Override |
| 94 | protected EClass eStaticClass() { |
| 95 | return RepositoryPackage.Literals.OPERATION_SIGNATURE; |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * <!-- begin-user-doc --> |
| 100 | * <!-- end-user-doc --> |
| 101 | * @generated |
| 102 | */ |
| 103 | public OperationInterface getInterface__OperationSignature() { |
| 104 | if (eContainerFeatureID() != RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE) return null; |
| 105 | return (OperationInterface)eContainer(); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * <!-- begin-user-doc --> |
| 110 | * <!-- end-user-doc --> |
| 111 | * @generated |
| 112 | */ |
| 113 | public NotificationChain basicSetInterface__OperationSignature(OperationInterface newInterface__OperationSignature, NotificationChain msgs) { |
| 114 | msgs = eBasicSetContainer((InternalEObject)newInterface__OperationSignature, RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE, msgs); |
| 115 | return msgs; |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * <!-- begin-user-doc --> |
| 120 | * <!-- end-user-doc --> |
| 121 | * @generated |
| 122 | */ |
| 123 | public void setInterface__OperationSignature(OperationInterface newInterface__OperationSignature) { |
| 124 | if (newInterface__OperationSignature != eInternalContainer() || (eContainerFeatureID() != RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE && newInterface__OperationSignature != null)) { |
| 125 | if (EcoreUtil.isAncestor(this, newInterface__OperationSignature)) |
| 126 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 127 | NotificationChain msgs = null; |
| 128 | if (eInternalContainer() != null) |
| 129 | msgs = eBasicRemoveFromContainer(msgs); |
| 130 | if (newInterface__OperationSignature != null) |
| 131 | msgs = ((InternalEObject)newInterface__OperationSignature).eInverseAdd(this, RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE, OperationInterface.class, msgs); |
| 132 | msgs = basicSetInterface__OperationSignature(newInterface__OperationSignature, msgs); |
| 133 | if (msgs != null) msgs.dispatch(); |
| 134 | } |
| 135 | else if (eNotificationRequired()) |
| 136 | eNotify(new ENotificationImpl(this, Notification.SET, RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE, newInterface__OperationSignature, newInterface__OperationSignature)); |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * The cached OCL expression body for the '{@link #ParameterNamesHaveToBeUniqueForASignature(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Parameter Names Have To Be Unique For ASignature</em>}' operation. |
| 141 | * <!-- begin-user-doc --> |
| 142 | * <!-- end-user-doc --> |
| 143 | * @see #ParameterNamesHaveToBeUniqueForASignature(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 144 | * @generated |
| 145 | * @ordered |
| 146 | */ |
| 147 | protected static final String PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP = "self.parameters__OperationSignature->isUnique(p : Parameter |\n"+" p.parameterName\n"+")"; |
| 148 | |
| 149 | /** |
| 150 | * The cached OCL invariant for the '{@link #ParameterNamesHaveToBeUniqueForASignature(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Parameter Names Have To Be Unique For ASignature</em>}' invariant operation. |
| 151 | * <!-- begin-user-doc --> |
| 152 | * <!-- end-user-doc --> |
| 153 | * @see #ParameterNamesHaveToBeUniqueForASignature(org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) |
| 154 | * @generated |
| 155 | * @ordered |
| 156 | */ |
| 157 | protected static Constraint PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV; |
| 158 | |
| 159 | /** |
| 160 | * <!-- begin-user-doc --> |
| 161 | * <!-- end-user-doc --> |
| 162 | * @generated |
| 163 | */ |
| 164 | public boolean ParameterNamesHaveToBeUniqueForASignature(DiagnosticChain diagnostics, Map<Object, Object> context) { |
| 165 | if (PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) { |
| 166 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 167 | helper.setContext(RepositoryPackage.Literals.OPERATION_SIGNATURE); |
| 168 | try { |
| 169 | PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV = helper.createInvariant(PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP); |
| 170 | } |
| 171 | catch (ParserException pe) { |
| 172 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 173 | } |
| 174 | } |
| 175 | if (!EOCL_ENV.createQuery(PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(this)) { |
| 176 | if (diagnostics != null) { |
| 177 | diagnostics.add |
| 178 | (new BasicDiagnostic |
| 179 | (Diagnostic.ERROR, |
| 180 | RepositoryValidator.DIAGNOSTIC_SOURCE, |
| 181 | RepositoryValidator.OPERATION_SIGNATURE__PARAMETER_NAMES_HAVE_TO_BE_UNIQUE_FOR_ASIGNATURE, |
| 182 | EcorePlugin.INSTANCE.getString("_UI_GenericInvariant_diagnostic", new Object[] { "ParameterNamesHaveToBeUniqueForASignature", EObjectValidator.getObjectLabel(this, context) }), |
| 183 | new Object [] { this })); |
| 184 | } |
| 185 | return false; |
| 186 | } |
| 187 | return true; |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * <!-- begin-user-doc --> |
| 192 | * <!-- end-user-doc --> |
| 193 | * @generated |
| 194 | */ |
| 195 | public DataType getReturnType__OperationSignature() { |
| 196 | if (returnType__OperationSignature != null && returnType__OperationSignature.eIsProxy()) { |
| 197 | InternalEObject oldReturnType__OperationSignature = (InternalEObject)returnType__OperationSignature; |
| 198 | returnType__OperationSignature = (DataType)eResolveProxy(oldReturnType__OperationSignature); |
| 199 | if (returnType__OperationSignature != oldReturnType__OperationSignature) { |
| 200 | if (eNotificationRequired()) |
| 201 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, RepositoryPackage.OPERATION_SIGNATURE__RETURN_TYPE_OPERATION_SIGNATURE, oldReturnType__OperationSignature, returnType__OperationSignature)); |
| 202 | } |
| 203 | } |
| 204 | return returnType__OperationSignature; |
| 205 | } |
| 206 | |
| 207 | /** |
| 208 | * <!-- begin-user-doc --> |
| 209 | * <!-- end-user-doc --> |
| 210 | * @generated |
| 211 | */ |
| 212 | public DataType basicGetReturnType__OperationSignature() { |
| 213 | return returnType__OperationSignature; |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * <!-- begin-user-doc --> |
| 218 | * <!-- end-user-doc --> |
| 219 | * @generated |
| 220 | */ |
| 221 | public void setReturnType__OperationSignature(DataType newReturnType__OperationSignature) { |
| 222 | DataType oldReturnType__OperationSignature = returnType__OperationSignature; |
| 223 | returnType__OperationSignature = newReturnType__OperationSignature; |
| 224 | if (eNotificationRequired()) |
| 225 | eNotify(new ENotificationImpl(this, Notification.SET, RepositoryPackage.OPERATION_SIGNATURE__RETURN_TYPE_OPERATION_SIGNATURE, oldReturnType__OperationSignature, returnType__OperationSignature)); |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * <!-- begin-user-doc --> |
| 230 | * <!-- end-user-doc --> |
| 231 | * @generated |
| 232 | */ |
| 233 | public EList<Parameter> getParameters__OperationSignature() { |
| 234 | if (parameters__OperationSignature == null) { |
| 235 | parameters__OperationSignature = new EObjectContainmentWithInverseEList<Parameter>(Parameter.class, this, RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE, RepositoryPackage.PARAMETER__OPERATION_SIGNATURE_PARAMETER); |
| 236 | } |
| 237 | return parameters__OperationSignature; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * <!-- begin-user-doc --> |
| 242 | * <!-- end-user-doc --> |
| 243 | * @generated |
| 244 | */ |
| 245 | @SuppressWarnings("unchecked") |
| 246 | @Override |
| 247 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 248 | switch (featureID) { |
| 249 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 250 | if (eInternalContainer() != null) |
| 251 | msgs = eBasicRemoveFromContainer(msgs); |
| 252 | return basicSetInterface__OperationSignature((OperationInterface)otherEnd, msgs); |
| 253 | case RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE: |
| 254 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getParameters__OperationSignature()).basicAdd(otherEnd, msgs); |
| 255 | } |
| 256 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * <!-- begin-user-doc --> |
| 261 | * <!-- end-user-doc --> |
| 262 | * @generated |
| 263 | */ |
| 264 | @Override |
| 265 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 266 | switch (featureID) { |
| 267 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 268 | return basicSetInterface__OperationSignature(null, msgs); |
| 269 | case RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE: |
| 270 | return ((InternalEList<?>)getParameters__OperationSignature()).basicRemove(otherEnd, msgs); |
| 271 | } |
| 272 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 273 | } |
| 274 | |
| 275 | /** |
| 276 | * <!-- begin-user-doc --> |
| 277 | * <!-- end-user-doc --> |
| 278 | * @generated |
| 279 | */ |
| 280 | @Override |
| 281 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 282 | switch (eContainerFeatureID()) { |
| 283 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 284 | return eInternalContainer().eInverseRemove(this, RepositoryPackage.OPERATION_INTERFACE__SIGNATURES_OPERATION_INTERFACE, OperationInterface.class, msgs); |
| 285 | } |
| 286 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * <!-- begin-user-doc --> |
| 291 | * <!-- end-user-doc --> |
| 292 | * @generated |
| 293 | */ |
| 294 | @Override |
| 295 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 296 | switch (featureID) { |
| 297 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 298 | return getInterface__OperationSignature(); |
| 299 | case RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE: |
| 300 | return getParameters__OperationSignature(); |
| 301 | case RepositoryPackage.OPERATION_SIGNATURE__RETURN_TYPE_OPERATION_SIGNATURE: |
| 302 | if (resolve) return getReturnType__OperationSignature(); |
| 303 | return basicGetReturnType__OperationSignature(); |
| 304 | } |
| 305 | return super.eGet(featureID, resolve, coreType); |
| 306 | } |
| 307 | |
| 308 | /** |
| 309 | * <!-- begin-user-doc --> |
| 310 | * <!-- end-user-doc --> |
| 311 | * @generated |
| 312 | */ |
| 313 | @SuppressWarnings("unchecked") |
| 314 | @Override |
| 315 | public void eSet(int featureID, Object newValue) { |
| 316 | switch (featureID) { |
| 317 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 318 | setInterface__OperationSignature((OperationInterface)newValue); |
| 319 | return; |
| 320 | case RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE: |
| 321 | getParameters__OperationSignature().clear(); |
| 322 | getParameters__OperationSignature().addAll((Collection<? extends Parameter>)newValue); |
| 323 | return; |
| 324 | case RepositoryPackage.OPERATION_SIGNATURE__RETURN_TYPE_OPERATION_SIGNATURE: |
| 325 | setReturnType__OperationSignature((DataType)newValue); |
| 326 | return; |
| 327 | } |
| 328 | super.eSet(featureID, newValue); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * <!-- begin-user-doc --> |
| 333 | * <!-- end-user-doc --> |
| 334 | * @generated |
| 335 | */ |
| 336 | @Override |
| 337 | public void eUnset(int featureID) { |
| 338 | switch (featureID) { |
| 339 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 340 | setInterface__OperationSignature((OperationInterface)null); |
| 341 | return; |
| 342 | case RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE: |
| 343 | getParameters__OperationSignature().clear(); |
| 344 | return; |
| 345 | case RepositoryPackage.OPERATION_SIGNATURE__RETURN_TYPE_OPERATION_SIGNATURE: |
| 346 | setReturnType__OperationSignature((DataType)null); |
| 347 | return; |
| 348 | } |
| 349 | super.eUnset(featureID); |
| 350 | } |
| 351 | |
| 352 | /** |
| 353 | * <!-- begin-user-doc --> |
| 354 | * <!-- end-user-doc --> |
| 355 | * @generated |
| 356 | */ |
| 357 | @Override |
| 358 | public boolean eIsSet(int featureID) { |
| 359 | switch (featureID) { |
| 360 | case RepositoryPackage.OPERATION_SIGNATURE__INTERFACE_OPERATION_SIGNATURE: |
| 361 | return getInterface__OperationSignature() != null; |
| 362 | case RepositoryPackage.OPERATION_SIGNATURE__PARAMETERS_OPERATION_SIGNATURE: |
| 363 | return parameters__OperationSignature != null && !parameters__OperationSignature.isEmpty(); |
| 364 | case RepositoryPackage.OPERATION_SIGNATURE__RETURN_TYPE_OPERATION_SIGNATURE: |
| 365 | return returnType__OperationSignature != null; |
| 366 | } |
| 367 | return super.eIsSet(featureID); |
| 368 | } |
| 369 | |
| 370 | /** |
| 371 | * The cached environment for evaluating OCL expressions. |
| 372 | * <!-- begin-user-doc --> |
| 373 | * <!-- end-user-doc --> |
| 374 | * @generated |
| 375 | * @ordered |
| 376 | */ |
| 377 | protected static final OCL EOCL_ENV = OCL.newInstance(); |
| 378 | |
| 379 | } //OperationSignatureImpl |