| /******************************************************************************* |
| * 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.Iterator; |
| import java.util.List; |
| 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.EObjectContainmentEList; |
| 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.OCLExpression; |
| import org.eclipse.ocl.pivot.Operation; |
| import org.eclipse.ocl.pivot.OperationCallExp; |
| import org.eclipse.ocl.pivot.Parameter; |
| 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.evaluation.Evaluator; |
| import org.eclipse.ocl.pivot.ids.IdResolver; |
| 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.collection.OrderedCollectionAtOperation; |
| 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.IntegerRange; |
| import org.eclipse.ocl.pivot.values.IntegerValue; |
| import org.eclipse.ocl.pivot.values.InvalidValueException; |
| import org.eclipse.ocl.pivot.values.OrderedSetValue; |
| import org.eclipse.ocl.pivot.values.SequenceValue; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model object '<em><b>Operation Call Exp</b></em>'. |
| * <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * </p> |
| * <ul> |
| * <li>{@link org.eclipse.ocl.pivot.internal.OperationCallExpImpl#getOwnedArguments <em>Owned Arguments</em>}</li> |
| * <li>{@link org.eclipse.ocl.pivot.internal.OperationCallExpImpl#getReferredOperation <em>Referred Operation</em>}</li> |
| * </ul> |
| * |
| * @generated |
| */ |
| public class OperationCallExpImpl |
| extends FeatureCallExpImpl |
| implements OperationCallExp { |
| |
| /** |
| * The cached value of the '{@link #getOwnedArguments() <em>Owned Arguments</em>}' containment reference list. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getOwnedArguments() |
| * @generated |
| * @ordered |
| */ |
| protected EList<OCLExpression> ownedArguments; |
| |
| /** |
| * The cached value of the '{@link #getReferredOperation() <em>Referred Operation</em>}' reference. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getReferredOperation() |
| * @generated |
| * @ordered |
| */ |
| protected Operation referredOperation; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected OperationCallExpImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return PivotPackage.Literals.OPERATION_CALL_EXP; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| @SuppressWarnings("null") |
| public @NonNull List<OCLExpression> getOwnedArguments() |
| { |
| if (ownedArguments == null) |
| { |
| ownedArguments = new EObjectContainmentEList<OCLExpression>(OCLExpression.class, this, PivotPackage.OPERATION_CALL_EXP__OWNED_ARGUMENTS); |
| } |
| return ownedArguments; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Operation getReferredOperation() { |
| if (referredOperation != null && referredOperation.eIsProxy()) |
| { |
| InternalEObject oldReferredOperation = (InternalEObject)referredOperation; |
| referredOperation = (Operation)eResolveProxy(oldReferredOperation); |
| if (referredOperation != oldReferredOperation) |
| { |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.RESOLVE, PivotPackage.OPERATION_CALL_EXP__REFERRED_OPERATION, oldReferredOperation, referredOperation)); |
| } |
| } |
| return referredOperation; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Operation basicGetReferredOperation() { |
| return referredOperation; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void setReferredOperation(Operation newReferredOperation) { |
| Operation oldReferredOperation = referredOperation; |
| referredOperation = newReferredOperation; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.OPERATION_CALL_EXP__REFERRED_OPERATION, oldReferredOperation, referredOperation)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public NotificationChain eInverseRemove(InternalEObject otherEnd, |
| int featureID, NotificationChain msgs) { |
| switch (featureID) |
| { |
| case PivotPackage.OPERATION_CALL_EXP__ANNOTATING_COMMENTS: |
| return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ANNOTATIONS: |
| return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_COMMENTS: |
| return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_EXTENSIONS: |
| return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_SOURCE: |
| return basicSetOwnedSource(null, msgs); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ARGUMENTS: |
| return ((InternalEList<?>)getOwnedArguments()).basicRemove(otherEnd, 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.OPERATION_CALL_EXP__ANNOTATING_COMMENTS: |
| return getAnnotatingComments(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ANNOTATIONS: |
| return getOwnedAnnotations(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_COMMENTS: |
| return getOwnedComments(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_EXTENSIONS: |
| return getOwnedExtensions(); |
| case PivotPackage.OPERATION_CALL_EXP__NAME: |
| return getName(); |
| case PivotPackage.OPERATION_CALL_EXP__IS_MANY: |
| return isIsMany(); |
| case PivotPackage.OPERATION_CALL_EXP__IS_REQUIRED: |
| return isIsRequired(); |
| case PivotPackage.OPERATION_CALL_EXP__TYPE: |
| if (resolve) return getType(); |
| return basicGetType(); |
| case PivotPackage.OPERATION_CALL_EXP__TYPE_VALUE: |
| return getTypeValue(); |
| case PivotPackage.OPERATION_CALL_EXP__IS_IMPLICIT: |
| return isIsImplicit(); |
| case PivotPackage.OPERATION_CALL_EXP__IS_SAFE: |
| return isIsSafe(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_SOURCE: |
| return getOwnedSource(); |
| case PivotPackage.OPERATION_CALL_EXP__IS_PRE: |
| return isIsPre(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ARGUMENTS: |
| return getOwnedArguments(); |
| case PivotPackage.OPERATION_CALL_EXP__REFERRED_OPERATION: |
| if (resolve) return getReferredOperation(); |
| return basicGetReferredOperation(); |
| } |
| 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.OPERATION_CALL_EXP__ANNOTATING_COMMENTS: |
| getAnnotatingComments().clear(); |
| getAnnotatingComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ANNOTATIONS: |
| getOwnedAnnotations().clear(); |
| getOwnedAnnotations().addAll((Collection<? extends Element>)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_COMMENTS: |
| getOwnedComments().clear(); |
| getOwnedComments().addAll((Collection<? extends Comment>)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_EXTENSIONS: |
| getOwnedExtensions().clear(); |
| getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__NAME: |
| setName((String)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_REQUIRED: |
| setIsRequired((Boolean)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__TYPE: |
| setType((Type)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__TYPE_VALUE: |
| setTypeValue((Type)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_IMPLICIT: |
| setIsImplicit((Boolean)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_SAFE: |
| setIsSafe((Boolean)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_SOURCE: |
| setOwnedSource((OCLExpression)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_PRE: |
| setIsPre((Boolean)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ARGUMENTS: |
| getOwnedArguments().clear(); |
| getOwnedArguments().addAll((Collection<? extends OCLExpression>)newValue); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__REFERRED_OPERATION: |
| setReferredOperation((Operation)newValue); |
| return; |
| } |
| eDynamicSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) |
| { |
| case PivotPackage.OPERATION_CALL_EXP__ANNOTATING_COMMENTS: |
| getAnnotatingComments().clear(); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ANNOTATIONS: |
| getOwnedAnnotations().clear(); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_COMMENTS: |
| getOwnedComments().clear(); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_EXTENSIONS: |
| getOwnedExtensions().clear(); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__NAME: |
| setName(NAME_EDEFAULT); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_REQUIRED: |
| setIsRequired(IS_REQUIRED_EDEFAULT); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__TYPE: |
| setType((Type)null); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__TYPE_VALUE: |
| setTypeValue((Type)null); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_IMPLICIT: |
| setIsImplicit(IS_IMPLICIT_EDEFAULT); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_SAFE: |
| setIsSafe(IS_SAFE_EDEFAULT); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_SOURCE: |
| setOwnedSource((OCLExpression)null); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__IS_PRE: |
| setIsPre(IS_PRE_EDEFAULT); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ARGUMENTS: |
| getOwnedArguments().clear(); |
| return; |
| case PivotPackage.OPERATION_CALL_EXP__REFERRED_OPERATION: |
| setReferredOperation((Operation)null); |
| return; |
| } |
| eDynamicUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) |
| { |
| case PivotPackage.OPERATION_CALL_EXP__ANNOTATING_COMMENTS: |
| return annotatingComments != null && !annotatingComments.isEmpty(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ANNOTATIONS: |
| return ownedAnnotations != null && !ownedAnnotations.isEmpty(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_COMMENTS: |
| return ownedComments != null && !ownedComments.isEmpty(); |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_EXTENSIONS: |
| return ownedExtensions != null && !ownedExtensions.isEmpty(); |
| case PivotPackage.OPERATION_CALL_EXP__NAME: |
| return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); |
| case PivotPackage.OPERATION_CALL_EXP__IS_MANY: |
| return isIsMany() != IS_MANY_EDEFAULT; |
| case PivotPackage.OPERATION_CALL_EXP__IS_REQUIRED: |
| return ((eFlags & IS_REQUIRED_EFLAG) != 0) != IS_REQUIRED_EDEFAULT; |
| case PivotPackage.OPERATION_CALL_EXP__TYPE: |
| return type != null; |
| case PivotPackage.OPERATION_CALL_EXP__TYPE_VALUE: |
| return typeValue != null; |
| case PivotPackage.OPERATION_CALL_EXP__IS_IMPLICIT: |
| return ((eFlags & IS_IMPLICIT_EFLAG) != 0) != IS_IMPLICIT_EDEFAULT; |
| case PivotPackage.OPERATION_CALL_EXP__IS_SAFE: |
| return ((eFlags & IS_SAFE_EFLAG) != 0) != IS_SAFE_EDEFAULT; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_SOURCE: |
| return ownedSource != null; |
| case PivotPackage.OPERATION_CALL_EXP__IS_PRE: |
| return ((eFlags & IS_PRE_EFLAG) != 0) != IS_PRE_EDEFAULT; |
| case PivotPackage.OPERATION_CALL_EXP__OWNED_ARGUMENTS: |
| return ownedArguments != null && !ownedArguments.isEmpty(); |
| case PivotPackage.OPERATION_CALL_EXP__REFERRED_OPERATION: |
| return referredOperation != 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.OPERATION_CALL_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.OPERATION_CALL_EXP___ALL_OWNED_ELEMENTS: |
| return allOwnedElements(); |
| case PivotPackage.OPERATION_CALL_EXP___GET_VALUE__TYPE_STRING: |
| return getValue((Type)arguments.get(0), (String)arguments.get(1)); |
| case PivotPackage.OPERATION_CALL_EXP___COMPATIBLE_BODY__VALUESPECIFICATION: |
| return CompatibleBody((ValueSpecification)arguments.get(0)); |
| case PivotPackage.OPERATION_CALL_EXP___GET_REFERRED_ELEMENT: |
| return getReferredElement(); |
| case PivotPackage.OPERATION_CALL_EXP___VALIDATE_ARGUMENT_COUNT__DIAGNOSTICCHAIN_MAP: |
| return validateArgumentCount((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1)); |
| case PivotPackage.OPERATION_CALL_EXP___VALIDATE_ARGUMENT_TYPE_IS_CONFORMANT__DIAGNOSTICCHAIN_MAP: |
| return validateArgumentTypeIsConformant((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.visitOperationCallExp(this); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| @Override |
| public Element getReferredElement() |
| { |
| return getReferredOperation(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateArgumentTypeIsConformant(final DiagnosticChain diagnostics, final Map<Object, Object> context) |
| { |
| /** |
| * |
| * inv validateArgumentTypeIsConformant: |
| * let operation : Operation[?] = self.referredOperation |
| * in |
| * let parameters : OrderedSet(Parameter) = operation.ownedParameters |
| * in |
| * let selfType : Type[?] = operation.owningClass |
| * in |
| * Sequence{1..ownedArguments->size() |
| * } |
| * ->forAll(i | |
| * let argument : OCLExpression[?] = ownedArguments->at(i) |
| * in |
| * let parameter : Parameter[?] = parameters->at(i) |
| * in |
| * let parameterType : Type[?] = parameter.type |
| * in |
| * let |
| * requiredType : Type[1] = if parameter.isTypeof |
| * then Class |
| * else parameterType.specializeIn(self, selfType) |
| * endif |
| * in argument.type.conformsTo(requiredType)) |
| */ |
| @NonNull /*@Caught*/ Object CAUGHT_forAll; |
| try { |
| final @Nullable /*@Thrown*/ Operation operation = this.getReferredOperation(); |
| if (operation == null) { |
| throw new InvalidValueException("Null source for \'pivot::Operation::ownedParameters\'"); |
| } |
| final @NonNull /*@Thrown*/ List<Parameter> parameters = operation.getOwnedParameters(); |
| final @Nullable /*@Thrown*/ org.eclipse.ocl.pivot.Class selfType_1 = operation.getOwningClass(); |
| final @NonNull /*@NonInvalid*/ Evaluator evaluator = PivotUtilInternal.getEvaluator(this); |
| final @NonNull /*@NonInvalid*/ IdResolver idResolver = evaluator.getIdResolver(); |
| final @NonNull /*@Thrown*/ List<OCLExpression> ownedArguments = this.getOwnedArguments(); |
| final @NonNull /*@Thrown*/ OrderedSetValue BOXED_ownedArguments = idResolver.createOrderedSetOfAll(PivotTables.ORD_CLSSid_OCLExpression, ownedArguments); |
| final @NonNull /*@Thrown*/ IntegerValue size = CollectionSizeOperation.INSTANCE.evaluate(BOXED_ownedArguments); |
| final @NonNull /*@Thrown*/ IntegerRange RNG = ValueUtil.createRange(PivotTables.INT_1, size); |
| final @NonNull /*@Thrown*/ SequenceValue Sequence = ValueUtil.createSequenceRange(PivotTables.SEQ_PRIMid_Integer, RNG); |
| @NonNull /*@Thrown*/ Object accumulator = ValueUtil.TRUE_VALUE; |
| @Nullable Iterator<?> ITERATOR_i = Sequence.iterator(); |
| /*@Thrown*/ boolean forAll; |
| while (true) { |
| if (!ITERATOR_i.hasNext()) { |
| if (accumulator == ValueUtil.TRUE_VALUE) { |
| forAll = (Boolean)accumulator; |
| } |
| else { |
| throw (InvalidValueException)accumulator; |
| } |
| break; |
| } |
| @Nullable /*@NonInvalid*/ IntegerValue i = (IntegerValue)ITERATOR_i.next(); |
| /** |
| * |
| * let argument : OCLExpression[?] = ownedArguments->at(i) |
| * in |
| * let parameter : Parameter[?] = parameters->at(i) |
| * in |
| * let parameterType : Type[?] = parameter.type |
| * in |
| * let |
| * requiredType : Type[1] = if parameter.isTypeof |
| * then Class |
| * else parameterType.specializeIn(self, selfType) |
| * endif |
| * in argument.type.conformsTo(requiredType) |
| */ |
| @NonNull /*@Caught*/ Object CAUGHT_conformsTo; |
| try { |
| final @Nullable /*@Thrown*/ OCLExpression argument = (OCLExpression)OrderedCollectionAtOperation.INSTANCE.evaluate(BOXED_ownedArguments, i); |
| final @NonNull /*@Thrown*/ OrderedSetValue BOXED_parameters = idResolver.createOrderedSetOfAll(PivotTables.ORD_CLSSid_Parameter, parameters); |
| final @Nullable /*@Thrown*/ Parameter parameter = (Parameter)OrderedCollectionAtOperation.INSTANCE.evaluate(BOXED_parameters, i); |
| if (parameter == null) { |
| throw new InvalidValueException("Null source for \'pivot::TypedElement::type\'"); |
| } |
| final @Nullable /*@Thrown*/ Type parameterType = parameter.getType(); |
| final @Nullable /*@Thrown*/ Boolean isTypeof = parameter.isIsTypeof(); |
| if (isTypeof == null) { |
| throw new InvalidValueException("Null if condition"); |
| } |
| @NonNull /*@Thrown*/ Type requiredType; |
| if (isTypeof) { |
| final @NonNull /*@NonInvalid*/ org.eclipse.ocl.pivot.Class TYP_Class_0 = idResolver.getClass(PivotTables.CLSSid_Class, null); |
| requiredType = TYP_Class_0; |
| } |
| else { |
| if (parameterType == null) { |
| throw new InvalidValueException("Null source for \'pivot::Type::specializeIn(pivot::CallExp,pivot::Type) : pivot::Type\'"); |
| } |
| final @NonNull /*@Thrown*/ Type specializeIn = parameterType.specializeIn(this, selfType_1); |
| requiredType = specializeIn; |
| } |
| if (argument == null) { |
| throw new InvalidValueException("Null source for \'pivot::TypedElement::type\'"); |
| } |
| final @Nullable /*@Thrown*/ Type type = argument.getType(); |
| final /*@Thrown*/ boolean conformsTo = OclTypeConformsToOperation.INSTANCE.evaluate(evaluator, type, requiredType).booleanValue(); |
| CAUGHT_conformsTo = conformsTo; |
| } |
| catch (Exception e) { |
| CAUGHT_conformsTo = ValueUtil.createInvalidValue(e); |
| } |
| // |
| if (CAUGHT_conformsTo == ValueUtil.FALSE_VALUE) { // Normal unsuccessful body evaluation result |
| forAll = ValueUtil.FALSE_VALUE; |
| break; // Stop immediately |
| } |
| else if (CAUGHT_conformsTo == ValueUtil.TRUE_VALUE) { // Normal successful body evaluation result |
| ; // Carry on |
| } |
| else if (CAUGHT_conformsTo instanceof InvalidValueException) { // Abnormal exception evaluation result |
| accumulator = CAUGHT_conformsTo; // Cache an exception failure |
| } |
| else { // Impossible badly typed result |
| accumulator = new InvalidValueException(PivotMessages.NonBooleanBody, "forAll"); |
| } |
| } |
| CAUGHT_forAll = forAll; |
| } |
| catch (Exception e) { |
| CAUGHT_forAll = ValueUtil.createInvalidValue(e); |
| } |
| if (CAUGHT_forAll == ValueUtil.TRUE_VALUE) { |
| return true; |
| } |
| if (diagnostics != null) { |
| int severity = Diagnostic.WARNING; |
| String message = StringUtil.bind(PivotMessages.ValidationConstraintIsNotSatisfied_ERROR_, new Object[]{"OperationCallExp", "ArgumentTypeIsConformant", EObjectValidator.getObjectLabel(this, context)}); |
| diagnostics.add(new BasicDiagnostic(severity, PivotValidator.DIAGNOSTIC_SOURCE, PivotValidator.OPERATION_CALL_EXP__VALIDATE_ARGUMENT_TYPE_IS_CONFORMANT, message, new Object [] { this })); |
| } |
| return false; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean validateArgumentCount(final DiagnosticChain diagnostics, final Map<Object, Object> context) |
| { |
| /** |
| * inv validateArgumentCount: |
| * ownedArguments->size() = |
| * referredOperation.ownedParameters->size() |
| */ |
| final @NonNull /*@NonInvalid*/ Evaluator evaluator = PivotUtilInternal.getEvaluator(this); |
| final @NonNull /*@NonInvalid*/ IdResolver idResolver = evaluator.getIdResolver(); |
| @NonNull /*@Caught*/ Object CAUGHT_eq; |
| try { |
| final @NonNull /*@Thrown*/ List<OCLExpression> ownedArguments = this.getOwnedArguments(); |
| final @NonNull /*@Thrown*/ OrderedSetValue BOXED_ownedArguments = idResolver.createOrderedSetOfAll(PivotTables.ORD_CLSSid_OCLExpression, ownedArguments); |
| final @NonNull /*@Thrown*/ IntegerValue size = CollectionSizeOperation.INSTANCE.evaluate(BOXED_ownedArguments); |
| final @Nullable /*@Thrown*/ Operation referredOperation = this.getReferredOperation(); |
| if (referredOperation == null) { |
| throw new InvalidValueException("Null source for \'pivot::Operation::ownedParameters\'"); |
| } |
| final @NonNull /*@Thrown*/ List<Parameter> ownedParameters = referredOperation.getOwnedParameters(); |
| final @NonNull /*@Thrown*/ OrderedSetValue BOXED_ownedParameters = idResolver.createOrderedSetOfAll(PivotTables.ORD_CLSSid_Parameter, ownedParameters); |
| final @NonNull /*@Thrown*/ IntegerValue size_0 = CollectionSizeOperation.INSTANCE.evaluate(BOXED_ownedParameters); |
| final /*@Thrown*/ boolean eq = size.equals(size_0); |
| 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[]{"OperationCallExp", "ArgumentCount", EObjectValidator.getObjectLabel(this, context)}); |
| diagnostics.add(new BasicDiagnostic(severity, PivotValidator.DIAGNOSTIC_SOURCE, PivotValidator.OPERATION_CALL_EXP__VALIDATE_ARGUMENT_COUNT, message, new Object [] { this })); |
| } |
| return false; |
| } |
| } //OperationCallExpImpl |