blob: 8f4b48c25a3529cc7bca8f3fe4cd736ba72ebb3d [file] [log] [blame]
/**
* <copyright>
*
* Copyright (c) 2013, 2019 Willink Transformations and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* E.D.Willink - Initial API and implementation
*
* </copyright>
*/
package org.eclipse.qvtd.pivot.qvtcore.impl;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.eclipse.emf.common.util.DiagnosticChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.evaluation.Executor;
import org.eclipse.ocl.pivot.ids.IdResolver;
import org.eclipse.ocl.pivot.ids.TypeId;
import org.eclipse.ocl.pivot.internal.VariableImpl;
import org.eclipse.ocl.pivot.library.logical.BooleanNotOperation;
import org.eclipse.ocl.pivot.library.oclany.OclAnyOclIsKindOfOperation;
import org.eclipse.ocl.pivot.library.oclany.OclComparableLessThanEqualOperation;
import org.eclipse.ocl.pivot.library.string.CGStringGetSeverityOperation;
import org.eclipse.ocl.pivot.library.string.CGStringLogDiagnosticOperation;
import org.eclipse.ocl.pivot.util.Visitor;
import org.eclipse.ocl.pivot.utilities.PivotUtil;
import org.eclipse.ocl.pivot.utilities.ValueUtil;
import org.eclipse.ocl.pivot.values.IntegerValue;
import org.eclipse.ocl.pivot.values.InvalidValueException;
import org.eclipse.qvtd.pivot.qvtcore.QVTcorePackage;
import org.eclipse.qvtd.pivot.qvtcore.QVTcoreTables;
import org.eclipse.qvtd.pivot.qvtcore.RealizedVariable;
import org.eclipse.qvtd.pivot.qvtcore.util.QVTcoreVisitor;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Realized Variable</b></em>'.
* <!-- end-user-doc -->
*
* @generated
*/
public class RealizedVariableImpl extends VariableImpl implements RealizedVariable {
/**
* The number of structural features of the '<em>Realized Variable</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int REALIZED_VARIABLE_FEATURE_COUNT = VariableImpl.VARIABLE_FEATURE_COUNT + 0;
/**
* The number of operations of the '<em>Realized Variable</em>' class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
* @ordered
*/
public static final int REALIZED_VARIABLE_OPERATION_COUNT = VariableImpl.VARIABLE_OPERATION_COUNT + 1;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected RealizedVariableImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return QVTcorePackage.Literals.REALIZED_VARIABLE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean validateNonDataTypeForType(final DiagnosticChain diagnostics, final Map<Object, Object> context) {
final @NonNull String constraintName = "RealizedVariable::NonDataTypeForType";
try {
/**
*
* inv NonDataTypeForType:
* let severity : Integer[1] = constraintName.getSeverity()
* in
* if severity <= 0
* then true
* else
* let result : Boolean[?] = not type.oclIsKindOf(DataType)
* in
* constraintName.logDiagnostic(self, null, diagnostics, context, null, severity, result, 0)
* endif
*/
final /*@NonInvalid*/ @NonNull Executor executor = PivotUtil.getExecutor(this, context);
final /*@NonInvalid*/ @NonNull IdResolver idResolver = executor.getIdResolver();
/*@Caught*/ @NonNull Object CAUGHT_severity_0;
try {
final /*@Thrown*/ @NonNull IntegerValue severity_0 = CGStringGetSeverityOperation.INSTANCE.evaluate(executor, QVTcorePackage.Literals.REALIZED_VARIABLE___VALIDATE_NON_DATA_TYPE_FOR_TYPE__DIAGNOSTICCHAIN_MAP);
CAUGHT_severity_0 = severity_0;
}
catch (Exception e) {
CAUGHT_severity_0 = ValueUtil.createInvalidValue(e);
}
if (CAUGHT_severity_0 instanceof InvalidValueException) {
throw (InvalidValueException)CAUGHT_severity_0;
}
final /*@Thrown*/ boolean le = OclComparableLessThanEqualOperation.INSTANCE.evaluate(executor, CAUGHT_severity_0, QVTcoreTables.INT_0).booleanValue();
/*@NonInvalid*/ boolean symbol_0;
if (le) {
symbol_0 = ValueUtil.TRUE_VALUE;
}
else {
/*@Caught*/ @NonNull Object CAUGHT_oclIsKindOf;
try {
final /*@NonInvalid*/ org.eclipse.ocl.pivot.@NonNull Class TYP_DataType = idResolver.getClass(QVTcoreTables.CLSSid_DataType, null);
final /*@NonInvalid*/ @Nullable Type type = this.getType();
final /*@Thrown*/ boolean oclIsKindOf = OclAnyOclIsKindOfOperation.INSTANCE.evaluate(executor, type, TYP_DataType).booleanValue();
CAUGHT_oclIsKindOf = oclIsKindOf;
}
catch (Exception e) {
CAUGHT_oclIsKindOf = ValueUtil.createInvalidValue(e);
}
final /*@NonInvalid*/ @Nullable Boolean result = BooleanNotOperation.INSTANCE.evaluate(CAUGHT_oclIsKindOf);
final /*@NonInvalid*/ boolean logDiagnostic = CGStringLogDiagnosticOperation.INSTANCE.evaluate(executor, TypeId.BOOLEAN, constraintName, this, (Object)null, diagnostics, context, (Object)null, CAUGHT_severity_0, result, QVTcoreTables.INT_0).booleanValue();
symbol_0 = logDiagnostic;
}
return Boolean.TRUE == symbol_0;
}
catch (Throwable e) {
return ValueUtil.validationFailedDiagnostic(constraintName, this, diagnostics, context, e);
}
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@SuppressWarnings("unchecked")
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException {
switch (operationID) {
case VariableImpl.VARIABLE_OPERATION_COUNT + 0:
return validateNonDataTypeForType((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1));
}
return super.eInvoke(operationID, arguments);
}
/**
* {@inheritDoc}
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return (R) ((QVTcoreVisitor<?>)visitor).visitRealizedVariable(this);
}
} //RealizedVariableImpl