| 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 | |
| 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.EObjectResolvingEList; |
| 18 | import org.eclipse.emf.ecore.util.EcoreUtil; |
| 19 | import org.eclipse.emf.ecore.util.InternalEList; |
| 20 | |
| 21 | import de.uka.ipd.sdq.pcm.core.entity.impl.EntityImpl; |
| 22 | import de.uka.ipd.sdq.pcm.repository.CompositeDataType; |
| 23 | import de.uka.ipd.sdq.pcm.repository.DataType; |
| 24 | import de.uka.ipd.sdq.pcm.repository.InnerDeclaration; |
| 25 | import de.uka.ipd.sdq.pcm.repository.Repository; |
| 26 | import de.uka.ipd.sdq.pcm.repository.RepositoryPackage; |
| 27 | |
| 28 | /** |
| 29 | * <!-- begin-user-doc --> |
| 30 | * An implementation of the model object '<em><b>Composite Data Type</b></em>'. |
| 31 | * <!-- end-user-doc --> |
| 32 | * <p> |
| 33 | * The following features are implemented: |
| 34 | * <ul> |
| 35 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.CompositeDataTypeImpl#getRepository__DataType <em>Repository Data Type</em>}</li> |
| 36 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.CompositeDataTypeImpl#getParentType_CompositeDataType <em>Parent Type Composite Data Type</em>}</li> |
| 37 | * <li>{@link de.uka.ipd.sdq.pcm.repository.impl.CompositeDataTypeImpl#getInnerDeclaration_CompositeDataType <em>Inner Declaration Composite Data Type</em>}</li> |
| 38 | * </ul> |
| 39 | * </p> |
| 40 | * |
| 41 | * @generated |
| 42 | */ |
| 43 | public class CompositeDataTypeImpl extends EntityImpl implements CompositeDataType { |
| 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 #getParentType_CompositeDataType() <em>Parent Type Composite Data Type</em>}' reference list. |
| 53 | * <!-- begin-user-doc --> |
| 54 | * <!-- end-user-doc --> |
| 55 | * @see #getParentType_CompositeDataType() |
| 56 | * @generated |
| 57 | * @ordered |
| 58 | */ |
| 59 | protected EList<CompositeDataType> parentType_CompositeDataType; |
| 60 | |
| 61 | /** |
| 62 | * The cached value of the '{@link #getInnerDeclaration_CompositeDataType() <em>Inner Declaration Composite Data Type</em>}' containment reference list. |
| 63 | * <!-- begin-user-doc --> |
| 64 | * <!-- end-user-doc --> |
| 65 | * @see #getInnerDeclaration_CompositeDataType() |
| 66 | * @generated |
| 67 | * @ordered |
| 68 | */ |
| 69 | protected EList<InnerDeclaration> innerDeclaration_CompositeDataType; |
| 70 | |
| 71 | /** |
| 72 | * <!-- begin-user-doc --> |
| 73 | * <!-- end-user-doc --> |
| 74 | * @generated |
| 75 | */ |
| 76 | protected CompositeDataTypeImpl() { |
| 77 | super(); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * <!-- begin-user-doc --> |
| 82 | * <!-- end-user-doc --> |
| 83 | * @generated |
| 84 | */ |
| 85 | @Override |
| 86 | protected EClass eStaticClass() { |
| 87 | return RepositoryPackage.Literals.COMPOSITE_DATA_TYPE; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * <!-- begin-user-doc --> |
| 92 | * <!-- end-user-doc --> |
| 93 | * @generated |
| 94 | */ |
| 95 | public Repository getRepository__DataType() { |
| 96 | if (eContainerFeatureID() != RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE) return null; |
| 97 | return (Repository)eContainer(); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * <!-- begin-user-doc --> |
| 102 | * <!-- end-user-doc --> |
| 103 | * @generated |
| 104 | */ |
| 105 | public NotificationChain basicSetRepository__DataType(Repository newRepository__DataType, NotificationChain msgs) { |
| 106 | msgs = eBasicSetContainer((InternalEObject)newRepository__DataType, RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE, msgs); |
| 107 | return msgs; |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * <!-- begin-user-doc --> |
| 112 | * <!-- end-user-doc --> |
| 113 | * @generated |
| 114 | */ |
| 115 | public void setRepository__DataType(Repository newRepository__DataType) { |
| 116 | if (newRepository__DataType != eInternalContainer() || (eContainerFeatureID() != RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE && newRepository__DataType != null)) { |
| 117 | if (EcoreUtil.isAncestor(this, newRepository__DataType)) |
| 118 | throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); |
| 119 | NotificationChain msgs = null; |
| 120 | if (eInternalContainer() != null) |
| 121 | msgs = eBasicRemoveFromContainer(msgs); |
| 122 | if (newRepository__DataType != null) |
| 123 | msgs = ((InternalEObject)newRepository__DataType).eInverseAdd(this, RepositoryPackage.REPOSITORY__DATA_TYPES_REPOSITORY, Repository.class, msgs); |
| 124 | msgs = basicSetRepository__DataType(newRepository__DataType, msgs); |
| 125 | if (msgs != null) msgs.dispatch(); |
| 126 | } |
| 127 | else if (eNotificationRequired()) |
| 128 | eNotify(new ENotificationImpl(this, Notification.SET, RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE, newRepository__DataType, newRepository__DataType)); |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * <!-- begin-user-doc --> |
| 133 | * <!-- end-user-doc --> |
| 134 | * @generated |
| 135 | */ |
| 136 | public EList<CompositeDataType> getParentType_CompositeDataType() { |
| 137 | if (parentType_CompositeDataType == null) { |
| 138 | parentType_CompositeDataType = new EObjectResolvingEList<CompositeDataType>(CompositeDataType.class, this, RepositoryPackage.COMPOSITE_DATA_TYPE__PARENT_TYPE_COMPOSITE_DATA_TYPE); |
| 139 | } |
| 140 | return parentType_CompositeDataType; |
| 141 | } |
| 142 | |
| 143 | /** |
| 144 | * <!-- begin-user-doc --> |
| 145 | * <!-- end-user-doc --> |
| 146 | * @generated |
| 147 | */ |
| 148 | public EList<InnerDeclaration> getInnerDeclaration_CompositeDataType() { |
| 149 | if (innerDeclaration_CompositeDataType == null) { |
| 150 | innerDeclaration_CompositeDataType = new EObjectContainmentWithInverseEList<InnerDeclaration>(InnerDeclaration.class, this, RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE, RepositoryPackage.INNER_DECLARATION__COMPOSITE_DATA_TYPE_INNER_DECLARATION); |
| 151 | } |
| 152 | return innerDeclaration_CompositeDataType; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * <!-- begin-user-doc --> |
| 157 | * <!-- end-user-doc --> |
| 158 | * @generated |
| 159 | */ |
| 160 | @SuppressWarnings("unchecked") |
| 161 | @Override |
| 162 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 163 | switch (featureID) { |
| 164 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 165 | if (eInternalContainer() != null) |
| 166 | msgs = eBasicRemoveFromContainer(msgs); |
| 167 | return basicSetRepository__DataType((Repository)otherEnd, msgs); |
| 168 | case RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE: |
| 169 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getInnerDeclaration_CompositeDataType()).basicAdd(otherEnd, msgs); |
| 170 | } |
| 171 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 172 | } |
| 173 | |
| 174 | /** |
| 175 | * <!-- begin-user-doc --> |
| 176 | * <!-- end-user-doc --> |
| 177 | * @generated |
| 178 | */ |
| 179 | @Override |
| 180 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 181 | switch (featureID) { |
| 182 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 183 | return basicSetRepository__DataType(null, msgs); |
| 184 | case RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE: |
| 185 | return ((InternalEList<?>)getInnerDeclaration_CompositeDataType()).basicRemove(otherEnd, msgs); |
| 186 | } |
| 187 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * <!-- begin-user-doc --> |
| 192 | * <!-- end-user-doc --> |
| 193 | * @generated |
| 194 | */ |
| 195 | @Override |
| 196 | public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { |
| 197 | switch (eContainerFeatureID()) { |
| 198 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 199 | return eInternalContainer().eInverseRemove(this, RepositoryPackage.REPOSITORY__DATA_TYPES_REPOSITORY, Repository.class, msgs); |
| 200 | } |
| 201 | return super.eBasicRemoveFromContainerFeature(msgs); |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * <!-- begin-user-doc --> |
| 206 | * <!-- end-user-doc --> |
| 207 | * @generated |
| 208 | */ |
| 209 | @Override |
| 210 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 211 | switch (featureID) { |
| 212 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 213 | return getRepository__DataType(); |
| 214 | case RepositoryPackage.COMPOSITE_DATA_TYPE__PARENT_TYPE_COMPOSITE_DATA_TYPE: |
| 215 | return getParentType_CompositeDataType(); |
| 216 | case RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE: |
| 217 | return getInnerDeclaration_CompositeDataType(); |
| 218 | } |
| 219 | return super.eGet(featureID, resolve, coreType); |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * <!-- begin-user-doc --> |
| 224 | * <!-- end-user-doc --> |
| 225 | * @generated |
| 226 | */ |
| 227 | @SuppressWarnings("unchecked") |
| 228 | @Override |
| 229 | public void eSet(int featureID, Object newValue) { |
| 230 | switch (featureID) { |
| 231 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 232 | setRepository__DataType((Repository)newValue); |
| 233 | return; |
| 234 | case RepositoryPackage.COMPOSITE_DATA_TYPE__PARENT_TYPE_COMPOSITE_DATA_TYPE: |
| 235 | getParentType_CompositeDataType().clear(); |
| 236 | getParentType_CompositeDataType().addAll((Collection<? extends CompositeDataType>)newValue); |
| 237 | return; |
| 238 | case RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE: |
| 239 | getInnerDeclaration_CompositeDataType().clear(); |
| 240 | getInnerDeclaration_CompositeDataType().addAll((Collection<? extends InnerDeclaration>)newValue); |
| 241 | return; |
| 242 | } |
| 243 | super.eSet(featureID, newValue); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * <!-- begin-user-doc --> |
| 248 | * <!-- end-user-doc --> |
| 249 | * @generated |
| 250 | */ |
| 251 | @Override |
| 252 | public void eUnset(int featureID) { |
| 253 | switch (featureID) { |
| 254 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 255 | setRepository__DataType((Repository)null); |
| 256 | return; |
| 257 | case RepositoryPackage.COMPOSITE_DATA_TYPE__PARENT_TYPE_COMPOSITE_DATA_TYPE: |
| 258 | getParentType_CompositeDataType().clear(); |
| 259 | return; |
| 260 | case RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE: |
| 261 | getInnerDeclaration_CompositeDataType().clear(); |
| 262 | return; |
| 263 | } |
| 264 | super.eUnset(featureID); |
| 265 | } |
| 266 | |
| 267 | /** |
| 268 | * <!-- begin-user-doc --> |
| 269 | * <!-- end-user-doc --> |
| 270 | * @generated |
| 271 | */ |
| 272 | @Override |
| 273 | public boolean eIsSet(int featureID) { |
| 274 | switch (featureID) { |
| 275 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: |
| 276 | return getRepository__DataType() != null; |
| 277 | case RepositoryPackage.COMPOSITE_DATA_TYPE__PARENT_TYPE_COMPOSITE_DATA_TYPE: |
| 278 | return parentType_CompositeDataType != null && !parentType_CompositeDataType.isEmpty(); |
| 279 | case RepositoryPackage.COMPOSITE_DATA_TYPE__INNER_DECLARATION_COMPOSITE_DATA_TYPE: |
| 280 | return innerDeclaration_CompositeDataType != null && !innerDeclaration_CompositeDataType.isEmpty(); |
| 281 | } |
| 282 | return super.eIsSet(featureID); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * <!-- begin-user-doc --> |
| 287 | * <!-- end-user-doc --> |
| 288 | * @generated |
| 289 | */ |
| 290 | @Override |
| 291 | public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { |
| 292 | if (baseClass == DataType.class) { |
| 293 | switch (derivedFeatureID) { |
| 294 | case RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE: return RepositoryPackage.DATA_TYPE__REPOSITORY_DATA_TYPE; |
| 295 | default: return -1; |
| 296 | } |
| 297 | } |
| 298 | return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); |
| 299 | } |
| 300 | |
| 301 | /** |
| 302 | * <!-- begin-user-doc --> |
| 303 | * <!-- end-user-doc --> |
| 304 | * @generated |
| 305 | */ |
| 306 | @Override |
| 307 | public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { |
| 308 | if (baseClass == DataType.class) { |
| 309 | switch (baseFeatureID) { |
| 310 | case RepositoryPackage.DATA_TYPE__REPOSITORY_DATA_TYPE: return RepositoryPackage.COMPOSITE_DATA_TYPE__REPOSITORY_DATA_TYPE; |
| 311 | default: return -1; |
| 312 | } |
| 313 | } |
| 314 | return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); |
| 315 | } |
| 316 | |
| 317 | } //CompositeDataTypeImpl |