| 1 | /** |
| 2 | * Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany |
| 3 | * |
| 4 | * $Id$ |
| 5 | */ |
| 6 | package de.uka.ipd.sdq.pcm.core.composition.impl; |
| 7 | |
| 8 | import java.util.Collection; |
| 9 | |
| 10 | import org.eclipse.emf.common.notify.Notification; |
| 11 | import org.eclipse.emf.common.notify.NotificationChain; |
| 12 | import org.eclipse.emf.common.util.EList; |
| 13 | import org.eclipse.emf.ecore.EClass; |
| 14 | import org.eclipse.emf.ecore.InternalEObject; |
| 15 | import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| 16 | import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; |
| 17 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 18 | import org.eclipse.emf.ecore.util.InternalEList; |
| 19 | |
| 20 | import de.uka.ipd.sdq.pcm.core.composition.AssemblyContext; |
| 21 | import de.uka.ipd.sdq.pcm.core.composition.ComposedStructure; |
| 22 | import de.uka.ipd.sdq.pcm.core.composition.CompositionPackage; |
| 23 | import de.uka.ipd.sdq.pcm.core.entity.impl.EntityImpl; |
| 24 | import de.uka.ipd.sdq.pcm.parameter.ParameterPackage; |
| 25 | import de.uka.ipd.sdq.pcm.parameter.VariableUsage; |
| 26 | import de.uka.ipd.sdq.pcm.repository.RepositoryComponent; |
| 27 | |
| 28 | /** |
| 29 | * <!-- begin-user-doc --> |
| 30 | * An implementation of the model object '<em><b>Assembly Context</b></em>'. |
| 31 | * <!-- end-user-doc --> |
| 32 | * <p> |
| 33 | * The following features are implemented: |
| 34 | * <ul> |
| 35 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.AssemblyContextImpl#getParentStructure__AssemblyContext <em>Parent Structure Assembly Context</em>}</li> |
| 36 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.AssemblyContextImpl#getEncapsulatedComponent__AssemblyContext <em>Encapsulated Component Assembly Context</em>}</li> |
| 37 | * <li>{@link de.uka.ipd.sdq.pcm.core.composition.impl.AssemblyContextImpl#getConfigParameterUsages__AssemblyContext <em>Config Parameter Usages Assembly Context</em>}</li> |
| 38 | * </ul> |
| 39 | * </p> |
| 40 | * |
| 41 | * @generated |
| 42 | */ |
| 43 | public class AssemblyContextImpl extends EntityImpl implements AssemblyContext { |
| 44 | /** |
| 45 | * <!-- begin-user-doc --> |
| 46 | * <!-- end-user-doc --> |
| 47 | * @generated |
| 48 | */ |
| 49 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
| 50 | |
| 51 | /** |
| 52 | * The cached value of the '{@link #getEncapsulatedComponent__AssemblyContext() <em>Encapsulated Component Assembly Context</em>}' reference. |
| 53 | * <!-- begin-user-doc --> |
| 54 | * <!-- end-user-doc --> |
| 55 | * @see #getEncapsulatedComponent__AssemblyContext() |
| 56 | * @generated |
| 57 | * @ordered |
| 58 | */ |
| 59 | protected RepositoryComponent encapsulatedComponent__AssemblyContext; |
| 60 | |
| 61 | /** |
| 62 | * The cached value of the '{@link #getConfigParameterUsages__AssemblyContext() <em>Config Parameter Usages Assembly Context</em>}' containment reference list. |
| 63 | * <!-- begin-user-doc --> |
| 64 | * <!-- end-user-doc --> |
| 65 | * @see #getConfigParameterUsages__AssemblyContext() |
| 66 | * @generated |
| 67 | * @ordered |
| 68 | */ |
| 69 | protected EList<VariableUsage> configParameterUsages__AssemblyContext; |
| 70 | |
| 71 | /** |
| 72 | * <!-- begin-user-doc --> |
| 73 | * <!-- end-user-doc --> |
| 74 | * @generated |
| 75 | */ |
| 76 | protected AssemblyContextImpl() { |
| 77 | super(); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * <!-- begin-user-doc --> |
| 82 | * <!-- end-user-doc --> |
| 83 | * @generated |
| 84 | */ |
| 85 | @Override |
| 86 | protected EClass eStaticClass() { |
| 87 | return CompositionPackage.Literals.ASSEMBLY_CONTEXT; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * <!-- begin-user-doc --> |
| 92 | * <!-- end-user-doc --> |
| 93 | * @generated |
| 94 | */ |
| 95 | public ComposedStructure getParentStructure__AssemblyContext() { |
| 96 | if (eContainerFeatureID() != CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT) return null; |
| 97 | return (ComposedStructure)eContainer(); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * <!-- begin-user-doc --> |
| 102 | * <!-- end-user-doc --> |
| 103 | * @generated |
| 104 | */ |
| 105 | public NotificationChain basicSetParentStructure__AssemblyContext(ComposedStructure newParentStructure__AssemblyContext, NotificationChain msgs) { |
| 106 | msgs = eBasicSetContainer((InternalEObject)newParentStructure__AssemblyContext, CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT, msgs); |
| 107 | return msgs; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * <!-- begin-user-doc --> |
| 112 | * <!-- end-user-doc --> |
| 113 | * @generated |
| 114 | */ |
| 115 | public void setParentStructure__AssemblyContext(ComposedStructure newParentStructure__AssemblyContext) { |
| 116 | if (newParentStructure__AssemblyContext != eInternalContainer() || (eContainerFeatureID() != CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT && newParentStructure__AssemblyContext != null)) { |
| 117 | if (EcoreUtil.isAncestor(this, newParentStructure__AssemblyContext)) |
| 118 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 119 | NotificationChain msgs = null; |
| 120 | if (eInternalContainer() != null) |
| 121 | msgs = eBasicRemoveFromContainer(msgs); |
| 122 | if (newParentStructure__AssemblyContext != null) |
| 123 | msgs = ((InternalEObject)newParentStructure__AssemblyContext).eInverseAdd(this, CompositionPackage.COMPOSED_STRUCTURE__ASSEMBLY_CONTEXTS_COMPOSED_STRUCTURE, ComposedStructure.class, msgs); |
| 124 | msgs = basicSetParentStructure__AssemblyContext(newParentStructure__AssemblyContext, msgs); |
| 125 | if (msgs != null) msgs.dispatch(); |
| 126 | } |
| 127 | else if (eNotificationRequired()) |
| 128 | eNotify(new ENotificationImpl(this, Notification.SET, CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT, newParentStructure__AssemblyContext, newParentStructure__AssemblyContext)); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | public RepositoryComponent getEncapsulatedComponent__AssemblyContext() { |
| 137 | if (encapsulatedComponent__AssemblyContext != null && encapsulatedComponent__AssemblyContext.eIsProxy()) { |
| 138 | InternalEObject oldEncapsulatedComponent__AssemblyContext = (InternalEObject)encapsulatedComponent__AssemblyContext; |
| 139 | encapsulatedComponent__AssemblyContext = (RepositoryComponent)eResolveProxy(oldEncapsulatedComponent__AssemblyContext); |
| 140 | if (encapsulatedComponent__AssemblyContext != oldEncapsulatedComponent__AssemblyContext) { |
| 141 | if (eNotificationRequired()) |
| 142 | eNotify(new ENotificationImpl(this, Notification.RESOLVE, CompositionPackage.ASSEMBLY_CONTEXT__ENCAPSULATED_COMPONENT_ASSEMBLY_CONTEXT, oldEncapsulatedComponent__AssemblyContext, encapsulatedComponent__AssemblyContext)); |
| 143 | } |
| 144 | } |
| 145 | return encapsulatedComponent__AssemblyContext; |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * <!-- begin-user-doc --> |
| 150 | * <!-- end-user-doc --> |
| 151 | * @generated |
| 152 | */ |
| 153 | public RepositoryComponent basicGetEncapsulatedComponent__AssemblyContext() { |
| 154 | return encapsulatedComponent__AssemblyContext; |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * <!-- begin-user-doc --> |
| 159 | * <!-- end-user-doc --> |
| 160 | * @generated |
| 161 | */ |
| 162 | public void setEncapsulatedComponent__AssemblyContext(RepositoryComponent newEncapsulatedComponent__AssemblyContext) { |
| 163 | RepositoryComponent oldEncapsulatedComponent__AssemblyContext = encapsulatedComponent__AssemblyContext; |
| 164 | encapsulatedComponent__AssemblyContext = newEncapsulatedComponent__AssemblyContext; |
| 165 | if (eNotificationRequired()) |
| 166 | eNotify(new ENotificationImpl(this, Notification.SET, CompositionPackage.ASSEMBLY_CONTEXT__ENCAPSULATED_COMPONENT_ASSEMBLY_CONTEXT, oldEncapsulatedComponent__AssemblyContext, encapsulatedComponent__AssemblyContext)); |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * <!-- begin-user-doc --> |
| 171 | * <!-- end-user-doc --> |
| 172 | * @generated |
| 173 | */ |
| 174 | public EList<VariableUsage> getConfigParameterUsages__AssemblyContext() { |
| 175 | if (configParameterUsages__AssemblyContext == null) { |
| 176 | configParameterUsages__AssemblyContext = new EObjectContainmentWithInverseEList<VariableUsage>(VariableUsage.class, this, CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT, ParameterPackage.VARIABLE_USAGE__ASSEMBLY_CONTEXT_VARIABLE_USAGE); |
| 177 | } |
| 178 | return configParameterUsages__AssemblyContext; |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * <!-- begin-user-doc --> |
| 183 | * <!-- end-user-doc --> |
| 184 | * @generated |
| 185 | */ |
| 186 | @SuppressWarnings("unchecked") |
| 187 | @Override |
| 188 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 189 | switch (featureID) { |
| 190 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 191 | if (eInternalContainer() != null) |
| 192 | msgs = eBasicRemoveFromContainer(msgs); |
| 193 | return basicSetParentStructure__AssemblyContext((ComposedStructure)otherEnd, msgs); |
| 194 | case CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT: |
| 195 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getConfigParameterUsages__AssemblyContext()).basicAdd(otherEnd, msgs); |
| 196 | } |
| 197 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * <!-- begin-user-doc --> |
| 202 | * <!-- end-user-doc --> |
| 203 | * @generated |
| 204 | */ |
| 205 | @Override |
| 206 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 207 | switch (featureID) { |
| 208 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 209 | return basicSetParentStructure__AssemblyContext(null, msgs); |
| 210 | case CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT: |
| 211 | return ((InternalEList<?>)getConfigParameterUsages__AssemblyContext()).basicRemove(otherEnd, msgs); |
| 212 | } |
| 213 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 214 | } |
| 215 | |
| 216 | /** |
| 217 | * <!-- begin-user-doc --> |
| 218 | * <!-- end-user-doc --> |
| 219 | * @generated |
| 220 | */ |
| 221 | @Override |
| 222 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 223 | switch (eContainerFeatureID()) { |
| 224 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 225 | return eInternalContainer().eInverseRemove(this, CompositionPackage.COMPOSED_STRUCTURE__ASSEMBLY_CONTEXTS_COMPOSED_STRUCTURE, ComposedStructure.class, msgs); |
| 226 | } |
| 227 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 228 | } |
| 229 | |
| 230 | /** |
| 231 | * <!-- begin-user-doc --> |
| 232 | * <!-- end-user-doc --> |
| 233 | * @generated |
| 234 | */ |
| 235 | @Override |
| 236 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 237 | switch (featureID) { |
| 238 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 239 | return getParentStructure__AssemblyContext(); |
| 240 | case CompositionPackage.ASSEMBLY_CONTEXT__ENCAPSULATED_COMPONENT_ASSEMBLY_CONTEXT: |
| 241 | if (resolve) return getEncapsulatedComponent__AssemblyContext(); |
| 242 | return basicGetEncapsulatedComponent__AssemblyContext(); |
| 243 | case CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT: |
| 244 | return getConfigParameterUsages__AssemblyContext(); |
| 245 | } |
| 246 | return super.eGet(featureID, resolve, coreType); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * <!-- begin-user-doc --> |
| 251 | * <!-- end-user-doc --> |
| 252 | * @generated |
| 253 | */ |
| 254 | @SuppressWarnings("unchecked") |
| 255 | @Override |
| 256 | public void eSet(int featureID, Object newValue) { |
| 257 | switch (featureID) { |
| 258 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 259 | setParentStructure__AssemblyContext((ComposedStructure)newValue); |
| 260 | return; |
| 261 | case CompositionPackage.ASSEMBLY_CONTEXT__ENCAPSULATED_COMPONENT_ASSEMBLY_CONTEXT: |
| 262 | setEncapsulatedComponent__AssemblyContext((RepositoryComponent)newValue); |
| 263 | return; |
| 264 | case CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT: |
| 265 | getConfigParameterUsages__AssemblyContext().clear(); |
| 266 | getConfigParameterUsages__AssemblyContext().addAll((Collection<? extends VariableUsage>)newValue); |
| 267 | return; |
| 268 | } |
| 269 | super.eSet(featureID, newValue); |
| 270 | } |
| 271 | |
| 272 | /** |
| 273 | * <!-- begin-user-doc --> |
| 274 | * <!-- end-user-doc --> |
| 275 | * @generated |
| 276 | */ |
| 277 | @Override |
| 278 | public void eUnset(int featureID) { |
| 279 | switch (featureID) { |
| 280 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 281 | setParentStructure__AssemblyContext((ComposedStructure)null); |
| 282 | return; |
| 283 | case CompositionPackage.ASSEMBLY_CONTEXT__ENCAPSULATED_COMPONENT_ASSEMBLY_CONTEXT: |
| 284 | setEncapsulatedComponent__AssemblyContext((RepositoryComponent)null); |
| 285 | return; |
| 286 | case CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT: |
| 287 | getConfigParameterUsages__AssemblyContext().clear(); |
| 288 | return; |
| 289 | } |
| 290 | super.eUnset(featureID); |
| 291 | } |
| 292 | |
| 293 | /** |
| 294 | * <!-- begin-user-doc --> |
| 295 | * <!-- end-user-doc --> |
| 296 | * @generated |
| 297 | */ |
| 298 | @Override |
| 299 | public boolean eIsSet(int featureID) { |
| 300 | switch (featureID) { |
| 301 | case CompositionPackage.ASSEMBLY_CONTEXT__PARENT_STRUCTURE_ASSEMBLY_CONTEXT: |
| 302 | return getParentStructure__AssemblyContext() != null; |
| 303 | case CompositionPackage.ASSEMBLY_CONTEXT__ENCAPSULATED_COMPONENT_ASSEMBLY_CONTEXT: |
| 304 | return encapsulatedComponent__AssemblyContext != null; |
| 305 | case CompositionPackage.ASSEMBLY_CONTEXT__CONFIG_PARAMETER_USAGES_ASSEMBLY_CONTEXT: |
| 306 | return configParameterUsages__AssemblyContext != null && !configParameterUsages__AssemblyContext.isEmpty(); |
| 307 | } |
| 308 | return super.eIsSet(featureID); |
| 309 | } |
| 310 | |
| 311 | } //AssemblyContextImpl |