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