| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package EssentialOCL.impl; |
| 8 | |
| 9 | import EssentialOCL.CollectionKind; |
| 10 | import EssentialOCL.CollectionLiteralExp; |
| 11 | import EssentialOCL.CollectionLiteralPart; |
| 12 | import EssentialOCL.EssentialOCLPackage; |
| 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.EObjectContainmentWithInverseEList; |
| 27 | import org.eclipse.emf.ecore.util.InternalEList; |
| 28 | |
| 29 | /** |
| 30 | * <!-- begin-user-doc --> |
| 31 | * An implementation of the model object '<em><b>Collection Literal Exp</b></em>'. |
| 32 | * <!-- end-user-doc --> |
| 33 | * <p> |
| 34 | * The following features are implemented: |
| 35 | * <ul> |
| 36 | * <li>{@link EssentialOCL.impl.CollectionLiteralExpImpl#getKind <em>Kind</em>}</li> |
| 37 | * <li>{@link EssentialOCL.impl.CollectionLiteralExpImpl#getPart <em>Part</em>}</li> |
| 38 | * </ul> |
| 39 | * </p> |
| 40 | * |
| 41 | * @generated |
| 42 | */ |
| 43 | public class CollectionLiteralExpImpl extends LiteralExpImpl implements CollectionLiteralExp { |
| 44 | /** |
| 45 | * The default value of the '{@link #getKind() <em>Kind</em>}' attribute. |
| 46 | * <!-- begin-user-doc --> |
| 47 | * <!-- end-user-doc --> |
| 48 | * @see #getKind() |
| 49 | * @generated |
| 50 | * @ordered |
| 51 | */ |
| 52 | protected static final CollectionKind KIND_EDEFAULT = CollectionKind.SET; |
| 53 | |
| 54 | /** |
| 55 | * The cached value of the '{@link #getKind() <em>Kind</em>}' attribute. |
| 56 | * <!-- begin-user-doc --> |
| 57 | * <!-- end-user-doc --> |
| 58 | * @see #getKind() |
| 59 | * @generated |
| 60 | * @ordered |
| 61 | */ |
| 62 | protected CollectionKind kind = KIND_EDEFAULT; |
| 63 | |
| 64 | /** |
| 65 | * The cached value of the '{@link #getPart() <em>Part</em>}' containment reference list. |
| 66 | * <!-- begin-user-doc --> |
| 67 | * <!-- end-user-doc --> |
| 68 | * @see #getPart() |
| 69 | * @generated |
| 70 | * @ordered |
| 71 | */ |
| 72 | protected EList<CollectionLiteralPart> part; |
| 73 | |
| 74 | /** |
| 75 | * <!-- begin-user-doc --> |
| 76 | * <!-- end-user-doc --> |
| 77 | * @generated |
| 78 | */ |
| 79 | protected CollectionLiteralExpImpl() { |
| 80 | super(); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * <!-- begin-user-doc --> |
| 85 | * <!-- end-user-doc --> |
| 86 | * @generated |
| 87 | */ |
| 88 | @Override |
| 89 | protected EClass eStaticClass() { |
| 90 | return EssentialOCLPackage.Literals.COLLECTION_LITERAL_EXP; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * <!-- begin-user-doc --> |
| 95 | * <!-- end-user-doc --> |
| 96 | * @generated |
| 97 | */ |
| 98 | public CollectionKind getKind() { |
| 99 | return kind; |
| 100 | } |
| 101 | |
| 102 | /** |
| 103 | * <!-- begin-user-doc --> |
| 104 | * <!-- end-user-doc --> |
| 105 | * @generated |
| 106 | */ |
| 107 | public void setKind(CollectionKind newKind) { |
| 108 | CollectionKind oldKind = kind; |
| 109 | kind = newKind == null ? KIND_EDEFAULT : newKind; |
| 110 | if (eNotificationRequired()) |
| 111 | eNotify(new ENotificationImpl(this, Notification.SET, EssentialOCLPackage.COLLECTION_LITERAL_EXP__KIND, oldKind, kind)); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * <!-- begin-user-doc --> |
| 116 | * <!-- end-user-doc --> |
| 117 | * @generated |
| 118 | */ |
| 119 | public EList<CollectionLiteralPart> getPart() { |
| 120 | if (part == null) { |
| 121 | part = new EObjectContainmentWithInverseEList<CollectionLiteralPart>(CollectionLiteralPart.class, this, EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART, EssentialOCLPackage.COLLECTION_LITERAL_PART__COLLECTION_LITERAL_EXP); |
| 122 | } |
| 123 | return part; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * <!-- begin-user-doc --> |
| 128 | * <!-- end-user-doc --> |
| 129 | * @generated |
| 130 | */ |
| 131 | @SuppressWarnings("unchecked") |
| 132 | @Override |
| 133 | public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 134 | switch (featureID) { |
| 135 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 136 | return ((InternalEList<InternalEObject>)(InternalEList<?>)getPart()).basicAdd(otherEnd, msgs); |
| 137 | } |
| 138 | return super.eInverseAdd(otherEnd, featureID, msgs); |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * <!-- begin-user-doc --> |
| 143 | * <!-- end-user-doc --> |
| 144 | * @generated |
| 145 | */ |
| 146 | @Override |
| 147 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 148 | switch (featureID) { |
| 149 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 150 | return ((InternalEList<?>)getPart()).basicRemove(otherEnd, msgs); |
| 151 | } |
| 152 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * <!-- begin-user-doc --> |
| 157 | * <!-- end-user-doc --> |
| 158 | * @generated |
| 159 | */ |
| 160 | @Override |
| 161 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 162 | switch (featureID) { |
| 163 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__KIND: |
| 164 | return getKind(); |
| 165 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 166 | return getPart(); |
| 167 | } |
| 168 | return super.eGet(featureID, resolve, coreType); |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * <!-- begin-user-doc --> |
| 173 | * <!-- end-user-doc --> |
| 174 | * @generated |
| 175 | */ |
| 176 | @SuppressWarnings("unchecked") |
| 177 | @Override |
| 178 | public void eSet(int featureID, Object newValue) { |
| 179 | switch (featureID) { |
| 180 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__KIND: |
| 181 | setKind((CollectionKind)newValue); |
| 182 | return; |
| 183 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 184 | getPart().clear(); |
| 185 | getPart().addAll((Collection<? extends CollectionLiteralPart>)newValue); |
| 186 | return; |
| 187 | } |
| 188 | super.eSet(featureID, newValue); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * <!-- begin-user-doc --> |
| 193 | * <!-- end-user-doc --> |
| 194 | * @generated |
| 195 | */ |
| 196 | @Override |
| 197 | public void eUnset(int featureID) { |
| 198 | switch (featureID) { |
| 199 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__KIND: |
| 200 | setKind(KIND_EDEFAULT); |
| 201 | return; |
| 202 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 203 | getPart().clear(); |
| 204 | return; |
| 205 | } |
| 206 | super.eUnset(featureID); |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * <!-- begin-user-doc --> |
| 211 | * <!-- end-user-doc --> |
| 212 | * @generated |
| 213 | */ |
| 214 | @Override |
| 215 | public boolean eIsSet(int featureID) { |
| 216 | switch (featureID) { |
| 217 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__KIND: |
| 218 | return kind != KIND_EDEFAULT; |
| 219 | case EssentialOCLPackage.COLLECTION_LITERAL_EXP__PART: |
| 220 | return part != null && !part.isEmpty(); |
| 221 | } |
| 222 | return super.eIsSet(featureID); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * <!-- begin-user-doc --> |
| 227 | * <!-- end-user-doc --> |
| 228 | * @generated |
| 229 | */ |
| 230 | @Override |
| 231 | public String toString() { |
| 232 | if (eIsProxy()) return super.toString(); |
| 233 | |
| 234 | StringBuffer result = new StringBuffer(super.toString()); |
| 235 | result.append(" (kind: "); |
| 236 | result.append(kind); |
| 237 | result.append(')'); |
| 238 | return result.toString(); |
| 239 | } |
| 240 | |
| 241 | } //CollectionLiteralExpImpl |