| 1 | /** |
| 2 | * <copyright> |
| 3 | * </copyright> |
| 4 | * |
| 5 | * $Id$ |
| 6 | */ |
| 7 | package edu.kit.ipd.sdq.completionfeaturemodel.impl; |
| 8 | |
| 9 | import QVTBase.Transformation; |
| 10 | import java.util.Collection; |
| 11 | |
| 12 | import org.eclipse.emf.common.notify.NotificationChain; |
| 13 | import org.eclipse.emf.common.util.EList; |
| 14 | import org.eclipse.emf.ecore.EClass; |
| 15 | import org.eclipse.emf.ecore.EClassifier; |
| 16 | import org.eclipse.emf.ecore.InternalEObject; |
| 17 | import org.eclipse.emf.ecore.util.EObjectContainmentEList; |
| 18 | import org.eclipse.emf.ecore.util.InternalEList; |
| 19 | import org.eclipse.ocl.ParserException; |
| 20 | import org.eclipse.ocl.ecore.OCL; |
| 21 | import org.eclipse.ocl.expressions.OCLExpression; |
| 22 | |
| 23 | import de.uka.ipd.sdq.featuremodel.impl.FeatureImpl; |
| 24 | import edu.kit.ipd.sdq.completionfeaturemodel.CompletionFeature; |
| 25 | import edu.kit.ipd.sdq.completionfeaturemodel.DisambiguationRule; |
| 26 | import edu.kit.ipd.sdq.completionfeaturemodel.FeatureState; |
| 27 | import edu.kit.ipd.sdq.completionfeaturemodel.completionfeaturemodelPackage; |
| 28 | |
| 29 | /** |
| 30 | * <!-- begin-user-doc --> |
| 31 | * An implementation of the model object '<em><b>Completion Feature</b></em>'. |
| 32 | * <!-- end-user-doc --> |
| 33 | * <p> |
| 34 | * The following features are implemented: |
| 35 | * <ul> |
| 36 | * <li>{@link edu.kit.ipd.sdq.completionfeaturemodel.impl.CompletionFeatureImpl#getCopyException <em>Copy Exception</em>}</li> |
| 37 | * <li>{@link edu.kit.ipd.sdq.completionfeaturemodel.impl.CompletionFeatureImpl#getDisambiguationRule <em>Disambiguation Rule</em>}</li> |
| 38 | * <li>{@link edu.kit.ipd.sdq.completionfeaturemodel.impl.CompletionFeatureImpl#getTransformationFragment <em>Transformation Fragment</em>}</li> |
| 39 | * <li>{@link edu.kit.ipd.sdq.completionfeaturemodel.impl.CompletionFeatureImpl#getFeatureState <em>Feature State</em>}</li> |
| 40 | * </ul> |
| 41 | * </p> |
| 42 | * |
| 43 | * @generated |
| 44 | */ |
| 45 | public class CompletionFeatureImpl extends FeatureImpl implements CompletionFeature { |
| 46 | /** |
| 47 | * The cached value of the '{@link #getCopyException() <em>Copy Exception</em>}' containment reference list. |
| 48 | * <!-- begin-user-doc --> |
| 49 | * <!-- end-user-doc --> |
| 50 | * @see #getCopyException() |
| 51 | * @generated |
| 52 | * @ordered |
| 53 | */ |
| 54 | protected EList<copyException.Exception> copyException; |
| 55 | |
| 56 | /** |
| 57 | * The cached value of the '{@link #getDisambiguationRule() <em>Disambiguation Rule</em>}' containment reference list. |
| 58 | * <!-- begin-user-doc --> |
| 59 | * <!-- end-user-doc --> |
| 60 | * @see #getDisambiguationRule() |
| 61 | * @generated |
| 62 | * @ordered |
| 63 | */ |
| 64 | protected EList<DisambiguationRule> disambiguationRule; |
| 65 | |
| 66 | /** |
| 67 | * The cached value of the '{@link #getTransformationFragment() <em>Transformation Fragment</em>}' containment reference list. |
| 68 | * <!-- begin-user-doc --> |
| 69 | * <!-- end-user-doc --> |
| 70 | * @see #getTransformationFragment() |
| 71 | * @generated |
| 72 | * @ordered |
| 73 | */ |
| 74 | protected EList<Transformation> transformationFragment; |
| 75 | |
| 76 | /** |
| 77 | * The default value of the '{@link #getFeatureState() <em>Feature State</em>}' attribute. |
| 78 | * <!-- begin-user-doc --> |
| 79 | * <!-- end-user-doc --> |
| 80 | * @see #getFeatureState() |
| 81 | * @generated |
| 82 | * @ordered |
| 83 | */ |
| 84 | protected static final FeatureState FEATURE_STATE_EDEFAULT = FeatureState.NOT_SET; |
| 85 | |
| 86 | /** |
| 87 | * <!-- begin-user-doc --> |
| 88 | * <!-- end-user-doc --> |
| 89 | * @generated |
| 90 | */ |
| 91 | protected CompletionFeatureImpl() { |
| 92 | super(); |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * <!-- begin-user-doc --> |
| 97 | * <!-- end-user-doc --> |
| 98 | * @generated |
| 99 | */ |
| 100 | @Override |
| 101 | protected EClass eStaticClass() { |
| 102 | return completionfeaturemodelPackage.Literals.COMPLETION_FEATURE; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * <!-- begin-user-doc --> |
| 107 | * <!-- end-user-doc --> |
| 108 | * @generated |
| 109 | */ |
| 110 | public EList<copyException.Exception> getCopyException() { |
| 111 | if (copyException == null) { |
| 112 | copyException = new EObjectContainmentEList<copyException.Exception>(copyException.Exception.class, this, completionfeaturemodelPackage.COMPLETION_FEATURE__COPY_EXCEPTION); |
| 113 | } |
| 114 | return copyException; |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * <!-- begin-user-doc --> |
| 119 | * <!-- end-user-doc --> |
| 120 | * @generated |
| 121 | */ |
| 122 | public EList<DisambiguationRule> getDisambiguationRule() { |
| 123 | if (disambiguationRule == null) { |
| 124 | disambiguationRule = new EObjectContainmentEList<DisambiguationRule>(DisambiguationRule.class, this, completionfeaturemodelPackage.COMPLETION_FEATURE__DISAMBIGUATION_RULE); |
| 125 | } |
| 126 | return disambiguationRule; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * <!-- begin-user-doc --> |
| 131 | * <!-- end-user-doc --> |
| 132 | * @generated |
| 133 | */ |
| 134 | public EList<Transformation> getTransformationFragment() { |
| 135 | if (transformationFragment == null) { |
| 136 | transformationFragment = new EObjectContainmentEList<Transformation>(Transformation.class, this, completionfeaturemodelPackage.COMPLETION_FEATURE__TRANSFORMATION_FRAGMENT); |
| 137 | } |
| 138 | return transformationFragment; |
| 139 | } |
| 140 | |
| 141 | |
| 142 | /** |
| 143 | * <!-- begin-user-doc --> |
| 144 | * returns the result of showFeatureState() |
| 145 | * showFeatureState is defined by an OCL expression. |
| 146 | * The FeatureState of a CompletionFeature is MANDATORY, if the CompletionFeature is included in its simpleMandatory.mandatoryChildren. |
| 147 | * It is OPTIONAL, if it is included in its simpleOptional.optionalChildren. |
| 148 | * If neither of these conditions applies, the FeatureState is NOT_SET. |
| 149 | * <!-- end-user-doc --> |
| 150 | * |
| 151 | * @generated NOT |
| 152 | */ |
| 153 | public FeatureState getFeatureState() { |
| 154 | return showFeatureState(); |
| 155 | } |
| 156 | |
| 157 | /** |
| 158 | * The cached OCL expression body for the '{@link #showFeatureState() <em>Show Feature State</em>}' operation. |
| 159 | * <!-- begin-user-doc --> |
| 160 | * <!-- end-user-doc --> |
| 161 | * @see #showFeatureState() |
| 162 | * @generated |
| 163 | * @ordered |
| 164 | */ |
| 165 | protected static final String SHOW_FEATURE_STATE__EOCL_EXP = "if (simpleMandatory->size() = 1 and simpleMandatory.mandatoryChildren->size() > 0 and simpleMandatory.mandatoryChildren->includes(self)) then FeatureState::MANDATORY"+ |
| 166 | " else ("+ |
| 167 | " if (simpleOptional->size() = 1 and simpleOptional.optionalChildren->size() > 0 and simpleOptional.optionalChildren->includes(self)) then FeatureState::OPTIONAL"+ |
| 168 | " else FeatureState::NOT_SET"+ |
| 169 | " endif"+ |
| 170 | " ) endif"; |
| 171 | |
| 172 | /** |
| 173 | * The cached OCL query for the '{@link #showFeatureState() <em>Show Feature State</em>}' query operation. |
| 174 | * <!-- begin-user-doc --> |
| 175 | * <!-- end-user-doc --> |
| 176 | * @see #showFeatureState() |
| 177 | * @generated |
| 178 | * @ordered |
| 179 | */ |
| 180 | protected static OCLExpression<EClassifier> SHOW_FEATURE_STATE__EOCL_QRY; |
| 181 | |
| 182 | /** |
| 183 | * <!-- begin-user-doc --> |
| 184 | * <!-- end-user-doc --> |
| 185 | * @generated |
| 186 | */ |
| 187 | public FeatureState showFeatureState() { |
| 188 | if (SHOW_FEATURE_STATE__EOCL_QRY == null) { |
| 189 | OCL.Helper helper = EOCL_ENV.createOCLHelper(); |
| 190 | helper.setOperationContext(completionfeaturemodelPackage.Literals.COMPLETION_FEATURE, completionfeaturemodelPackage.Literals.COMPLETION_FEATURE.getEAllOperations().get(2)); |
| 191 | try { |
| 192 | SHOW_FEATURE_STATE__EOCL_QRY = helper.createQuery(SHOW_FEATURE_STATE__EOCL_EXP); |
| 193 | } |
| 194 | catch (ParserException pe) { |
| 195 | throw new UnsupportedOperationException(pe.getLocalizedMessage()); |
| 196 | } |
| 197 | } |
| 198 | OCL.Query query = EOCL_ENV.createQuery(SHOW_FEATURE_STATE__EOCL_QRY); |
| 199 | return (FeatureState) query.evaluate(this); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * <!-- begin-user-doc --> |
| 204 | * <!-- end-user-doc --> |
| 205 | * @generated |
| 206 | */ |
| 207 | @Override |
| 208 | public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { |
| 209 | switch (featureID) { |
| 210 | case completionfeaturemodelPackage.COMPLETION_FEATURE__COPY_EXCEPTION: |
| 211 | return ((InternalEList<?>)getCopyException()).basicRemove(otherEnd, msgs); |
| 212 | case completionfeaturemodelPackage.COMPLETION_FEATURE__DISAMBIGUATION_RULE: |
| 213 | return ((InternalEList<?>)getDisambiguationRule()).basicRemove(otherEnd, msgs); |
| 214 | case completionfeaturemodelPackage.COMPLETION_FEATURE__TRANSFORMATION_FRAGMENT: |
| 215 | return ((InternalEList<?>)getTransformationFragment()).basicRemove(otherEnd, msgs); |
| 216 | } |
| 217 | return super.eInverseRemove(otherEnd, featureID, msgs); |
| 218 | } |
| 219 | |
| 220 | /** |
| 221 | * <!-- begin-user-doc --> |
| 222 | * <!-- end-user-doc --> |
| 223 | * @generated |
| 224 | */ |
| 225 | @Override |
| 226 | public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| 227 | switch (featureID) { |
| 228 | case completionfeaturemodelPackage.COMPLETION_FEATURE__COPY_EXCEPTION: |
| 229 | return getCopyException(); |
| 230 | case completionfeaturemodelPackage.COMPLETION_FEATURE__DISAMBIGUATION_RULE: |
| 231 | return getDisambiguationRule(); |
| 232 | case completionfeaturemodelPackage.COMPLETION_FEATURE__TRANSFORMATION_FRAGMENT: |
| 233 | return getTransformationFragment(); |
| 234 | case completionfeaturemodelPackage.COMPLETION_FEATURE__FEATURE_STATE: |
| 235 | return getFeatureState(); |
| 236 | } |
| 237 | return super.eGet(featureID, resolve, coreType); |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * <!-- begin-user-doc --> |
| 242 | * <!-- end-user-doc --> |
| 243 | * @generated |
| 244 | */ |
| 245 | @SuppressWarnings("unchecked") |
| 246 | @Override |
| 247 | public void eSet(int featureID, Object newValue) { |
| 248 | switch (featureID) { |
| 249 | case completionfeaturemodelPackage.COMPLETION_FEATURE__COPY_EXCEPTION: |
| 250 | getCopyException().clear(); |
| 251 | getCopyException().addAll((Collection<? extends copyException.Exception>)newValue); |
| 252 | return; |
| 253 | case completionfeaturemodelPackage.COMPLETION_FEATURE__DISAMBIGUATION_RULE: |
| 254 | getDisambiguationRule().clear(); |
| 255 | getDisambiguationRule().addAll((Collection<? extends DisambiguationRule>)newValue); |
| 256 | return; |
| 257 | case completionfeaturemodelPackage.COMPLETION_FEATURE__TRANSFORMATION_FRAGMENT: |
| 258 | getTransformationFragment().clear(); |
| 259 | getTransformationFragment().addAll((Collection<? extends Transformation>)newValue); |
| 260 | return; |
| 261 | } |
| 262 | super.eSet(featureID, newValue); |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * <!-- begin-user-doc --> |
| 267 | * <!-- end-user-doc --> |
| 268 | * @generated |
| 269 | */ |
| 270 | @Override |
| 271 | public void eUnset(int featureID) { |
| 272 | switch (featureID) { |
| 273 | case completionfeaturemodelPackage.COMPLETION_FEATURE__COPY_EXCEPTION: |
| 274 | getCopyException().clear(); |
| 275 | return; |
| 276 | case completionfeaturemodelPackage.COMPLETION_FEATURE__DISAMBIGUATION_RULE: |
| 277 | getDisambiguationRule().clear(); |
| 278 | return; |
| 279 | case completionfeaturemodelPackage.COMPLETION_FEATURE__TRANSFORMATION_FRAGMENT: |
| 280 | getTransformationFragment().clear(); |
| 281 | return; |
| 282 | } |
| 283 | super.eUnset(featureID); |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * <!-- begin-user-doc --> |
| 288 | * <!-- end-user-doc --> |
| 289 | * @generated |
| 290 | */ |
| 291 | @Override |
| 292 | public boolean eIsSet(int featureID) { |
| 293 | switch (featureID) { |
| 294 | case completionfeaturemodelPackage.COMPLETION_FEATURE__COPY_EXCEPTION: |
| 295 | return copyException != null && !copyException.isEmpty(); |
| 296 | case completionfeaturemodelPackage.COMPLETION_FEATURE__DISAMBIGUATION_RULE: |
| 297 | return disambiguationRule != null && !disambiguationRule.isEmpty(); |
| 298 | case completionfeaturemodelPackage.COMPLETION_FEATURE__TRANSFORMATION_FRAGMENT: |
| 299 | return transformationFragment != null && !transformationFragment.isEmpty(); |
| 300 | case completionfeaturemodelPackage.COMPLETION_FEATURE__FEATURE_STATE: |
| 301 | return getFeatureState() != FEATURE_STATE_EDEFAULT; |
| 302 | } |
| 303 | return super.eIsSet(featureID); |
| 304 | } |
| 305 | |
| 306 | } //CompletionFeatureImpl |