| /******************************************************************************* |
| * Copyright (c) 2010, 2014 E.D.Willink and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * E.D.Willink - Initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.ocl.pivot.internal; |
| |
| import java.lang.reflect.InvocationTargetException; |
| import java.util.Collection; |
| import java.util.Map; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.common.notify.NotificationChain; |
| import org.eclipse.emf.common.util.BasicDiagnostic; |
| import org.eclipse.emf.common.util.Diagnostic; |
| import org.eclipse.emf.common.util.DiagnosticChain; |
| import org.eclipse.emf.common.util.EList; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.InternalEObject; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.emf.ecore.util.EObjectValidator; |
| import org.eclipse.emf.ecore.util.InternalEList; |
| import org.eclipse.jdt.annotation.NonNull; |
| import org.eclipse.jdt.annotation.Nullable; |
| import org.eclipse.ocl.pivot.Comment; |
| import org.eclipse.ocl.pivot.Element; |
| import org.eclipse.ocl.pivot.ElementExtension; |
| import org.eclipse.ocl.pivot.IterateExp; |
| import org.eclipse.ocl.pivot.Iteration; |
| import org.eclipse.ocl.pivot.OCLExpression; |
| import org.eclipse.ocl.pivot.PivotPackage; |
| import org.eclipse.ocl.pivot.PivotTables; |
| import org.eclipse.ocl.pivot.ReferringElement; |
| import org.eclipse.ocl.pivot.Type; |
| import org.eclipse.ocl.pivot.ValueSpecification; |
| import org.eclipse.ocl.pivot.Variable; |
| import org.eclipse.ocl.pivot.evaluation.Evaluator; |
| import org.eclipse.ocl.pivot.internal.utilities.PivotUtilInternal; |
| import org.eclipse.ocl.pivot.library.classifier.OclTypeConformsToOperation; |
| import org.eclipse.ocl.pivot.library.collection.CollectionSizeOperation; |
| import org.eclipse.ocl.pivot.library.oclany.OclAnyOclAsSetOperation; |
| import org.eclipse.ocl.pivot.messages.PivotMessages; |
| import org.eclipse.ocl.pivot.util.PivotValidator; |
| import org.eclipse.ocl.pivot.util.Visitor; |
| import org.eclipse.ocl.pivot.utilities.StringUtil; |
| import org.eclipse.ocl.pivot.utilities.ValueUtil; |
| import org.eclipse.ocl.pivot.values.IntegerValue; |
| import org.eclipse.ocl.pivot.values.InvalidValueException; |
| import org.eclipse.ocl.pivot.values.SetValue; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Iterate Exp</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.IterateExpImpl#getOwnedResult <em>Owned Result</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class IterateExpImpl extends LoopExpImpl implements IterateExp |
| { |
| /** |
| * The cached value of the '{@link #getOwnedResult() <em>Owned Result</em>}' containment reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedResult() |
| * @generated |
| * @ordered |
| */ |
| protected Variable ownedResult; |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected IterateExpImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return PivotPackage.Literals.ITERATE_EXP; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Variable getOwnedResult() |
| { |
| return ownedResult; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public NotificationChain basicSetOwnedResult(Variable newOwnedResult, NotificationChain msgs) |
| { |
| Variable oldOwnedResult = ownedResult; |
| ownedResult = newOwnedResult; |
| if (eNotificationRequired()) |
| { |
| ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PivotPackage.ITERATE_EXP__OWNED_RESULT, oldOwnedResult, newOwnedResult); |
| if (msgs == null) msgs = notification; else msgs.add(notification); |
| } |
| return msgs; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setOwnedResult(Variable newOwnedResult) |
| { |
| if (newOwnedResult != ownedResult) |
| { |
| NotificationChain msgs = null; |
| if (ownedResult != null) |
| msgs = ((InternalEObject)ownedResult).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PivotPackage.ITERATE_EXP__OWNED_RESULT, null, msgs); |
| if (newOwnedResult != null) |
| msgs = ((InternalEObject)newOwnedResult).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PivotPackage.ITERATE_EXP__OWNED_RESULT, null, msgs); |
| msgs = basicSetOwnedResult(newOwnedResult, msgs); |
| if (msgs != null) msgs.dispatch(); |
| } |
| else if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.ITERATE_EXP__OWNED_RESULT, newOwnedResult, newOwnedResult)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.ITERATE_EXP__ANNOTATING_COMMENTS: |
| return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_ANNOTATIONS: |
| return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_COMMENTS: |
| return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_EXTENSIONS: |
| return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_SOURCE: |
| return basicSetOwnedSource(null, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_BODY: |
| return basicSetOwnedBody(null, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_ITERATORS: |
| return ((InternalEList<?>)getOwnedIterators()).basicRemove(otherEnd, msgs); |
| case PivotPackage.ITERATE_EXP__OWNED_RESULT: |
| return basicSetOwnedResult(null, msgs); |
| } |
| return eDynamicInverseRemove(otherEnd, featureID, msgs); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.ITERATE_EXP__ANNOTATING_COMMENTS: |
| return getAnnotatingComments(); |
| case PivotPackage.ITERATE_EXP__OWNED_ANNOTATIONS: |
| return getOwnedAnnotations(); |
| case PivotPackage.ITERATE_EXP__OWNED_COMMENTS: |
| return getOwnedComments(); |
| case PivotPackage.ITERATE_EXP__OWNED_EXTENSIONS: |
| return getOwnedExtensions(); |
| case PivotPackage.ITERATE_EXP__NAME: |
| return getName(); |
| case PivotPackage.ITERATE_EXP__IS_MANY: |
| return isIsMany(); |
| case PivotPackage.ITERATE_EXP__IS_REQUIRED: |
| return isIsRequired(); |
| case PivotPackage.ITERATE_EXP__TYPE: |
| if (resolve) return getType(); |
| return basicGetType(); |
| case PivotPackage.ITERATE_EXP__TYPE_VALUE: |
| return getTypeValue(); |
| case PivotPackage.ITERATE_EXP__IS_IMPLICIT: |
| return isIsImplicit(); |
| case PivotPackage.ITERATE_EXP__OWNED_SOURCE: |
| return getOwnedSource(); |
| case PivotPackage.ITERATE_EXP__OWNED_BODY: |
| return getOwnedBody(); |
| case PivotPackage.ITERATE_EXP__OWNED_ITERATORS: |
| return getOwnedIterators(); |
| case PivotPackage.ITERATE_EXP__REFERRED_ITERATION: |
| if (resolve) return getReferredIteration(); |
| return basicGetReferredIteration(); |
| case PivotPackage.ITERATE_EXP__OWNED_RESULT: |
| return getOwnedResult(); |
| } |
| return eDynamicGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @SuppressWarnings("unchecked") |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.ITERATE_EXP__ANNOTATING_COMMENTS: |
| getAnnotatingComments().clear(); |
| getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_ANNOTATIONS: |
| getOwnedAnnotations().clear(); |
| getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_COMMENTS: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_EXTENSIONS: |
| getOwnedExtensions().clear(); |
| getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__NAME: |
| setName((String)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__IS_REQUIRED: |
| setIsRequired((Boolean)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__TYPE: |
| setType((Type)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__TYPE_VALUE: |
| setTypeValue((Type)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__IS_IMPLICIT: |
| setIsImplicit((Boolean)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_SOURCE: |
| setOwnedSource((OCLExpression)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_BODY: |
| setOwnedBody((OCLExpression)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_ITERATORS: |
| getOwnedIterators().clear(); |
| getOwnedIterators().addAll((Collection<? extends Variable>)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__REFERRED_ITERATION: |
| setReferredIteration((Iteration)newValue); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_RESULT: |
| setOwnedResult((Variable)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.ITERATE_EXP__ANNOTATING_COMMENTS: |
| getAnnotatingComments().clear(); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_ANNOTATIONS: |
| getOwnedAnnotations().clear(); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_COMMENTS: |
| getOwnedComments().clear(); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_EXTENSIONS: |
| getOwnedExtensions().clear(); |
| return; |
| case PivotPackage.ITERATE_EXP__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case PivotPackage.ITERATE_EXP__IS_REQUIRED: |
| setIsRequired(IS_REQUIRED_EDEFAULT); |
| return; |
| case PivotPackage.ITERATE_EXP__TYPE: |
| setType((Type)null); |
| return; |
| case PivotPackage.ITERATE_EXP__TYPE_VALUE: |
| setTypeValue((Type)null); |
| return; |
| case PivotPackage.ITERATE_EXP__IS_IMPLICIT: |
| setIsImplicit(IS_IMPLICIT_EDEFAULT); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_SOURCE: |
| setOwnedSource((OCLExpression)null); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_BODY: |
| setOwnedBody((OCLExpression)null); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_ITERATORS: |
| getOwnedIterators().clear(); |
| return; |
| case PivotPackage.ITERATE_EXP__REFERRED_ITERATION: |
| setReferredIteration((Iteration)null); |
| return; |
| case PivotPackage.ITERATE_EXP__OWNED_RESULT: |
| setOwnedResult((Variable)null); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case PivotPackage.ITERATE_EXP__ANNOTATING_COMMENTS: |
| return annotatingComments != null && !annotatingComments.isEmpty(); |
| case PivotPackage.ITERATE_EXP__OWNED_ANNOTATIONS: |
| return ownedAnnotations != null && !ownedAnnotations.isEmpty(); |
| case PivotPackage.ITERATE_EXP__OWNED_COMMENTS: |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case PivotPackage.ITERATE_EXP__OWNED_EXTENSIONS: |
| return ownedExtensions != null && !ownedExtensions.isEmpty(); |
| case PivotPackage.ITERATE_EXP__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case PivotPackage.ITERATE_EXP__IS_MANY: |
| return isIsMany() != IS_MANY_EDEFAULT; |
| case PivotPackage.ITERATE_EXP__IS_REQUIRED: |
| return ((eFlags & IS_REQUIRED_EFLAG) != 0) != IS_REQUIRED_EDEFAULT; |
| case PivotPackage.ITERATE_EXP__TYPE: |
| return type != null; |
| case PivotPackage.ITERATE_EXP__TYPE_VALUE: |
| return typeValue != null; |
| case PivotPackage.ITERATE_EXP__IS_IMPLICIT: |
| return ((eFlags & IS_IMPLICIT_EFLAG) != 0) != IS_IMPLICIT_EDEFAULT; |
| case PivotPackage.ITERATE_EXP__OWNED_SOURCE: |
| return ownedSource != null; |
| case PivotPackage.ITERATE_EXP__OWNED_BODY: |
| return ownedBody != null; |
| case PivotPackage.ITERATE_EXP__OWNED_ITERATORS: |
| return ownedIterators != null && !ownedIterators.isEmpty(); |
| case PivotPackage.ITERATE_EXP__REFERRED_ITERATION: |
| return referredIteration != null; |
| case PivotPackage.ITERATE_EXP__OWNED_RESULT: |
| return ownedResult != null; |
| } |
| return eDynamicIsSet(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public int eDerivedOperationID(int baseOperationID, Class<?> baseClass) |
| { |
| if (baseClass == ReferringElement.class) |
| { |
| switch (baseOperationID) |
| { |
| case PivotPackage.REFERRING_ELEMENT___GET_REFERRED_ELEMENT: return PivotPackage.ITERATE_EXP___GET_REFERRED_ELEMENT; |
| default: return -1; |
| } |
| } |
| return super.eDerivedOperationID(baseOperationID, baseClass); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| @SuppressWarnings("unchecked") |
| public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException |
| { |
| switch (operationID) |
| { |
| case PivotPackage.ITERATE_EXP___ALL_OWNED_ELEMENTS: |
| return allOwnedElements(); |
| case PivotPackage.ITERATE_EXP___GET_VALUE__TYPE_STRING: |
| return getValue((Type)arguments.get(0), (String)arguments.get(1)); |
| case PivotPackage.ITERATE_EXP___COMPATIBLE_BODY__VALUESPECIFICATION: |
| return CompatibleBody((ValueSpecification)arguments.get(0)); |
| case PivotPackage.ITERATE_EXP___VALIDATE_NO_INITIALIZERS__DIAGNOSTICCHAIN_MAP: |
| return validateNoInitializers((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| case PivotPackage.ITERATE_EXP___VALIDATE_SOURCE_IS_COLLECTION__DIAGNOSTICCHAIN_MAP: |
| return validateSourceIsCollection((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| case PivotPackage.ITERATE_EXP___GET_REFERRED_ELEMENT: |
| return getReferredElement(); |
| case PivotPackage.ITERATE_EXP___VALIDATE_BODY_TYPE_CONFORMS_TO_RESULT_TYPE__DIAGNOSTICCHAIN_MAP: |
| return validateBodyTypeConformsToResultType((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| case PivotPackage.ITERATE_EXP___VALIDATE_ONE_INITIALIZER__DIAGNOSTICCHAIN_MAP: |
| return validateOneInitializer((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| case PivotPackage.ITERATE_EXP___VALIDATE_TYPE_IS_RESULT_TYPE__DIAGNOSTICCHAIN_MAP: |
| return validateTypeIsResultType((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| } |
| return eDynamicInvoke(operationID, arguments); |
| } |
| |
| @Override |
| public <R> R accept(@NonNull Visitor<R> visitor) { |
| return visitor.visitIterateExp(this); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public Element getReferredElement() |
| { |
| return getReferredIteration(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateTypeIsResultType(final DiagnosticChain diagnostics, final Map<Object, Object> context) |
| { |
| /** |
| * inv validateTypeIsResultType: type = ownedResult.type |
| */ |
| @NonNull /*@Caught*/ Object CAUGHT_eq; |
| try { |
| final @Nullable /*@Thrown*/ Type type = this.getType(); |
| final @Nullable /*@Thrown*/ Variable ownedResult = this.getOwnedResult(); |
| if (ownedResult == null) { |
| throw new InvalidValueException("Null source for \'pivot::TypedElement::type\'"); |
| } |
| final @Nullable /*@Thrown*/ Type type_0 = ownedResult.getType(); |
| final /*@Thrown*/ boolean eq = (type != null) && (type_0 != null) ? (type.getTypeId() == type_0.getTypeId()) : ValueUtil.throwBooleanInvalidValueException("null equal input"); |
| ; |
| CAUGHT_eq = eq; |
| } |
| catch (Exception e) { |
| CAUGHT_eq = ValueUtil.createInvalidValue(e); |
| } |
| if (CAUGHT_eq == ValueUtil.TRUE_VALUE) { |
| return true; |
| } |
| if (diagnostics != null) { |
| int severity = Diagnostic.WARNING; |
| String message = StringUtil.bind(PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, new Object[]{"IterateExp", "TypeIsResultType", EObjectValidator.getObjectLabel(this, context)}); |
| diagnostics.add(new BasicDiagnostic(severity, PivotValidator.DIAGNOSTIC_SOURCE, PivotValidator.ITERATE_EXP__VALIDATE_TYPE_IS_RESULT_TYPE, message, new Object [] { this })); |
| } |
| return false; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateBodyTypeConformsToResultType(final DiagnosticChain diagnostics, final Map<Object, Object> context) |
| { |
| /** |
| * |
| * inv validateBodyTypeConformsToResultType: |
| * ownedBody.type.conformsTo(ownedResult.type) |
| */ |
| final @NonNull /*@NonInvalid*/ Evaluator evaluator = PivotUtilInternal.getEvaluator(this); |
| @NonNull /*@Caught*/ Object CAUGHT_conformsTo; |
| try { |
| final @Nullable /*@Thrown*/ OCLExpression ownedBody = this.getOwnedBody(); |
| if (ownedBody == null) { |
| throw new InvalidValueException("Null source for \'pivot::TypedElement::type\'"); |
| } |
| final @Nullable /*@Thrown*/ Type type = ownedBody.getType(); |
| final @Nullable /*@Thrown*/ Variable ownedResult = this.getOwnedResult(); |
| if (ownedResult == null) { |
| throw new InvalidValueException("Null source for \'pivot::TypedElement::type\'"); |
| } |
| final @Nullable /*@Thrown*/ Type type_0 = ownedResult.getType(); |
| final /*@Thrown*/ boolean conformsTo = OclTypeConformsToOperation.INSTANCE.evaluate(evaluator, type, type_0).booleanValue(); |
| CAUGHT_conformsTo = conformsTo; |
| } |
| catch (Exception e) { |
| CAUGHT_conformsTo = ValueUtil.createInvalidValue(e); |
| } |
| if (CAUGHT_conformsTo == ValueUtil.TRUE_VALUE) { |
| return true; |
| } |
| if (diagnostics != null) { |
| int severity = Diagnostic.WARNING; |
| String message = StringUtil.bind(PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, new Object[]{"IterateExp", "BodyTypeConformsToResultType", EObjectValidator.getObjectLabel(this, context)}); |
| diagnostics.add(new BasicDiagnostic(severity, PivotValidator.DIAGNOSTIC_SOURCE, PivotValidator.ITERATE_EXP__VALIDATE_BODY_TYPE_CONFORMS_TO_RESULT_TYPE, message, new Object [] { this })); |
| } |
| return false; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateOneInitializer(final DiagnosticChain diagnostics, final Map<Object, Object> context) |
| { |
| /** |
| * |
| * inv validateOneInitializer: self.ownedResult.ownedInit->size() = 1 |
| */ |
| final @NonNull /*@NonInvalid*/ Evaluator evaluator = PivotUtilInternal.getEvaluator(this); |
| @NonNull /*@Caught*/ Object CAUGHT_eq; |
| try { |
| final @Nullable /*@Thrown*/ Variable ownedResult = this.getOwnedResult(); |
| if (ownedResult == null) { |
| throw new InvalidValueException("Null source for \'pivot::Variable::ownedInit\'"); |
| } |
| final @Nullable /*@Thrown*/ OCLExpression ownedInit = ownedResult.getOwnedInit(); |
| final @NonNull /*@Thrown*/ SetValue oclAsSet = OclAnyOclAsSetOperation.INSTANCE.evaluate(evaluator, PivotTables.SET_CLSSid_OCLExpression, ownedInit); |
| final @NonNull /*@Thrown*/ IntegerValue size = CollectionSizeOperation.INSTANCE.evaluate(oclAsSet); |
| final /*@Thrown*/ boolean eq = size.equals(PivotTables.INT_1); |
| CAUGHT_eq = eq; |
| } |
| catch (Exception e) { |
| CAUGHT_eq = ValueUtil.createInvalidValue(e); |
| } |
| if (CAUGHT_eq == ValueUtil.TRUE_VALUE) { |
| return true; |
| } |
| if (diagnostics != null) { |
| int severity = Diagnostic.WARNING; |
| String message = StringUtil.bind(PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, new Object[]{"IterateExp", "OneInitializer", EObjectValidator.getObjectLabel(this, context)}); |
| diagnostics.add(new BasicDiagnostic(severity, PivotValidator.DIAGNOSTIC_SOURCE, PivotValidator.ITERATE_EXP__VALIDATE_ONE_INITIALIZER, message, new Object [] { this })); |
| } |
| return false; |
| } |
| |
| } //IterateExpImpl |