blob: 294f931d9d03d6efa6d362346eb3af412db2d4e9 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010, 2017 Willink Transformations 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.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.InternalEList;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.ocl.pivot.CallExp;
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.PivotPackage;
import org.eclipse.ocl.pivot.PivotTables;
import org.eclipse.ocl.pivot.Type;
import org.eclipse.ocl.pivot.ValueSpecification;
import org.eclipse.ocl.pivot.ids.TypeId;
import org.eclipse.ocl.pivot.internal.utilities.PivotUtilInternal;
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.ValueUtil;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Call Exp</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.eclipse.ocl.pivot.internal.CallExpImpl#isIsImplicit <em>Is Implicit</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.CallExpImpl#isIsSafe <em>Is Safe</em>}</li>
* <li>{@link org.eclipse.ocl.pivot.internal.CallExpImpl#getOwnedSource <em>Owned Source</em>}</li>
* </ul>
*
* @generated
*/
public abstract class CallExpImpl
extends OCLExpressionImpl
implements CallExp {
/**
* The default value of the '{@link #isIsImplicit() <em>Is Implicit</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsImplicit()
* @generated
* @ordered
*/
protected static final boolean IS_IMPLICIT_EDEFAULT = false;
/**
* The flag representing the value of the '{@link #isIsImplicit() <em>Is Implicit</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsImplicit()
* @generated
* @ordered
*/
protected static final int IS_IMPLICIT_EFLAG = 1 << 9;
/**
* The default value of the '{@link #isIsSafe() <em>Is Safe</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsSafe()
* @generated
* @ordered
*/
protected static final boolean IS_SAFE_EDEFAULT = false;
/**
* The flag representing the value of the '{@link #isIsSafe() <em>Is Safe</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #isIsSafe()
* @generated
* @ordered
*/
protected static final int IS_SAFE_EFLAG = 1 << 10;
/**
* The cached value of the '{@link #getOwnedSource() <em>Owned Source</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOwnedSource()
* @generated
* @ordered
*/
protected OCLExpression ownedSource;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected CallExpImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return PivotPackage.Literals.CALL_EXP;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isIsImplicit()
{
return (eFlags & IS_IMPLICIT_EFLAG) != 0;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public OCLExpression getOwnedSource() {
return ownedSource;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedSource(OCLExpression newOwnedSource, NotificationChain msgs)
{
OCLExpression oldOwnedSource = ownedSource;
ownedSource = newOwnedSource;
if (eNotificationRequired())
{
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PivotPackage.CALL_EXP__OWNED_SOURCE, oldOwnedSource, newOwnedSource);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setOwnedSource(OCLExpression newOwnedSource) {
if (newOwnedSource != ownedSource)
{
NotificationChain msgs = null;
if (ownedSource != null)
msgs = ((InternalEObject)ownedSource).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PivotPackage.CALL_EXP__OWNED_SOURCE, null, msgs);
if (newOwnedSource != null)
msgs = ((InternalEObject)newOwnedSource).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PivotPackage.CALL_EXP__OWNED_SOURCE, null, msgs);
msgs = basicSetOwnedSource(newOwnedSource, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.CALL_EXP__OWNED_SOURCE, newOwnedSource, newOwnedSource));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean validateTypeIsNotInvalid(final DiagnosticChain diagnostics, final Map<Object, Object> context)
{
/**
*
* inv TypeIsNotInvalid:
* let severity : Integer[1] = 'CallExp::TypeIsNotInvalid'.getSeverity()
* in
* if severity <= 0
* then true
* else
* let result : Boolean[1] = type <> OclInvalid
* in
* 'CallExp::TypeIsNotInvalid'.logDiagnostic(self, null, diagnostics, context, null, severity, result, 0)
* endif
*/
final /*@NonInvalid*/ org.eclipse.ocl.pivot.evaluation.@NonNull Executor executor = PivotUtilInternal.getExecutor(this);
final /*@NonInvalid*/ org.eclipse.ocl.pivot.ids.@NonNull IdResolver idResolver = executor.getIdResolver();
final /*@NonInvalid*/ org.eclipse.ocl.pivot.values.@NonNull IntegerValue severity_0 = CGStringGetSeverityOperation.INSTANCE.evaluate(executor, PivotTables.STR_CallExp_c_c_TypeIsNotInvalid);
final /*@NonInvalid*/ boolean le = OclComparableLessThanEqualOperation.INSTANCE.evaluate(executor, severity_0, PivotTables.INT_0).booleanValue();
/*@NonInvalid*/ boolean symbol_0;
if (le) {
symbol_0 = ValueUtil.TRUE_VALUE;
}
else {
final /*@NonInvalid*/ org.eclipse.ocl.pivot.@NonNull Class TYP_OclInvalid = idResolver.getClass(TypeId.OCL_INVALID, null);
final /*@NonInvalid*/ org.eclipse.ocl.pivot.@Nullable Type type = this.getType();
final /*@NonInvalid*/ boolean result = (type != null) ? (type.getTypeId() != TYP_OclInvalid.getTypeId()) : true;
final /*@NonInvalid*/ boolean logDiagnostic = CGStringLogDiagnosticOperation.INSTANCE.evaluate(executor, TypeId.BOOLEAN, PivotTables.STR_CallExp_c_c_TypeIsNotInvalid, this, (Object)null, diagnostics, context, (Object)null, severity_0, result, PivotTables.INT_0).booleanValue();
symbol_0 = logDiagnostic;
}
return Boolean.TRUE == symbol_0;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setIsImplicit(boolean newIsImplicit)
{
boolean oldIsImplicit = (eFlags & IS_IMPLICIT_EFLAG) != 0;
if (newIsImplicit) eFlags |= IS_IMPLICIT_EFLAG; else eFlags &= ~IS_IMPLICIT_EFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.CALL_EXP__IS_IMPLICIT, oldIsImplicit, newIsImplicit));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean isIsSafe()
{
return (eFlags & IS_SAFE_EFLAG) != 0;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void setIsSafe(boolean newIsSafe)
{
boolean oldIsSafe = (eFlags & IS_SAFE_EFLAG) != 0;
if (newIsSafe) eFlags |= IS_SAFE_EFLAG; else eFlags &= ~IS_SAFE_EFLAG;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, PivotPackage.CALL_EXP__IS_SAFE, oldIsSafe, newIsSafe));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd,
int featureID, NotificationChain msgs) {
switch (featureID)
{
case PivotPackage.CALL_EXP__ANNOTATING_COMMENTS:
return ((InternalEList<?>)getAnnotatingComments()).basicRemove(otherEnd, msgs);
case PivotPackage.CALL_EXP__OWNED_ANNOTATIONS:
return ((InternalEList<?>)getOwnedAnnotations()).basicRemove(otherEnd, msgs);
case PivotPackage.CALL_EXP__OWNED_COMMENTS:
return ((InternalEList<?>)getOwnedComments()).basicRemove(otherEnd, msgs);
case PivotPackage.CALL_EXP__OWNED_EXTENSIONS:
return ((InternalEList<?>)getOwnedExtensions()).basicRemove(otherEnd, msgs);
case PivotPackage.CALL_EXP__OWNED_SOURCE:
return basicSetOwnedSource(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.CALL_EXP__ANNOTATING_COMMENTS:
return getAnnotatingComments();
case PivotPackage.CALL_EXP__OWNED_ANNOTATIONS:
return getOwnedAnnotations();
case PivotPackage.CALL_EXP__OWNED_COMMENTS:
return getOwnedComments();
case PivotPackage.CALL_EXP__OWNED_EXTENSIONS:
return getOwnedExtensions();
case PivotPackage.CALL_EXP__NAME:
return getName();
case PivotPackage.CALL_EXP__IS_MANY:
return isIsMany();
case PivotPackage.CALL_EXP__IS_REQUIRED:
return isIsRequired();
case PivotPackage.CALL_EXP__TYPE:
if (resolve) return getType();
return basicGetType();
case PivotPackage.CALL_EXP__TYPE_VALUE:
return getTypeValue();
case PivotPackage.CALL_EXP__IS_IMPLICIT:
return isIsImplicit();
case PivotPackage.CALL_EXP__IS_SAFE:
return isIsSafe();
case PivotPackage.CALL_EXP__OWNED_SOURCE:
return getOwnedSource();
}
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.CALL_EXP__ANNOTATING_COMMENTS:
getAnnotatingComments().clear();
getAnnotatingComments().addAll((Collection<? extends Comment>)newValue);
return;
case PivotPackage.CALL_EXP__OWNED_ANNOTATIONS:
getOwnedAnnotations().clear();
getOwnedAnnotations().addAll((Collection<? extends Element>)newValue);
return;
case PivotPackage.CALL_EXP__OWNED_COMMENTS:
getOwnedComments().clear();
getOwnedComments().addAll((Collection<? extends Comment>)newValue);
return;
case PivotPackage.CALL_EXP__OWNED_EXTENSIONS:
getOwnedExtensions().clear();
getOwnedExtensions().addAll((Collection<? extends ElementExtension>)newValue);
return;
case PivotPackage.CALL_EXP__NAME:
setName((String)newValue);
return;
case PivotPackage.CALL_EXP__IS_REQUIRED:
setIsRequired((Boolean)newValue);
return;
case PivotPackage.CALL_EXP__TYPE:
setType((Type)newValue);
return;
case PivotPackage.CALL_EXP__TYPE_VALUE:
setTypeValue((Type)newValue);
return;
case PivotPackage.CALL_EXP__IS_IMPLICIT:
setIsImplicit((Boolean)newValue);
return;
case PivotPackage.CALL_EXP__IS_SAFE:
setIsSafe((Boolean)newValue);
return;
case PivotPackage.CALL_EXP__OWNED_SOURCE:
setOwnedSource((OCLExpression)newValue);
return;
}
eDynamicSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID)
{
case PivotPackage.CALL_EXP__ANNOTATING_COMMENTS:
getAnnotatingComments().clear();
return;
case PivotPackage.CALL_EXP__OWNED_ANNOTATIONS:
getOwnedAnnotations().clear();
return;
case PivotPackage.CALL_EXP__OWNED_COMMENTS:
getOwnedComments().clear();
return;
case PivotPackage.CALL_EXP__OWNED_EXTENSIONS:
getOwnedExtensions().clear();
return;
case PivotPackage.CALL_EXP__NAME:
setName(NAME_EDEFAULT);
return;
case PivotPackage.CALL_EXP__IS_REQUIRED:
setIsRequired(IS_REQUIRED_EDEFAULT);
return;
case PivotPackage.CALL_EXP__TYPE:
setType((Type)null);
return;
case PivotPackage.CALL_EXP__TYPE_VALUE:
setTypeValue((Type)null);
return;
case PivotPackage.CALL_EXP__IS_IMPLICIT:
setIsImplicit(IS_IMPLICIT_EDEFAULT);
return;
case PivotPackage.CALL_EXP__IS_SAFE:
setIsSafe(IS_SAFE_EDEFAULT);
return;
case PivotPackage.CALL_EXP__OWNED_SOURCE:
setOwnedSource((OCLExpression)null);
return;
}
eDynamicUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID)
{
case PivotPackage.CALL_EXP__ANNOTATING_COMMENTS:
return annotatingComments != null && !annotatingComments.isEmpty();
case PivotPackage.CALL_EXP__OWNED_ANNOTATIONS:
return ownedAnnotations != null && !ownedAnnotations.isEmpty();
case PivotPackage.CALL_EXP__OWNED_COMMENTS:
return ownedComments != null && !ownedComments.isEmpty();
case PivotPackage.CALL_EXP__OWNED_EXTENSIONS:
return ownedExtensions != null && !ownedExtensions.isEmpty();
case PivotPackage.CALL_EXP__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
case PivotPackage.CALL_EXP__IS_MANY:
return isIsMany() != IS_MANY_EDEFAULT;
case PivotPackage.CALL_EXP__IS_REQUIRED:
return ((eFlags & IS_REQUIRED_EFLAG) != 0) != IS_REQUIRED_EDEFAULT;
case PivotPackage.CALL_EXP__TYPE:
return type != null;
case PivotPackage.CALL_EXP__TYPE_VALUE:
return typeValue != null;
case PivotPackage.CALL_EXP__IS_IMPLICIT:
return ((eFlags & IS_IMPLICIT_EFLAG) != 0) != IS_IMPLICIT_EDEFAULT;
case PivotPackage.CALL_EXP__IS_SAFE:
return ((eFlags & IS_SAFE_EFLAG) != 0) != IS_SAFE_EDEFAULT;
case PivotPackage.CALL_EXP__OWNED_SOURCE:
return ownedSource != null;
}
return eDynamicIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
@SuppressWarnings("unchecked")
public Object eInvoke(int operationID, EList<?> arguments) throws InvocationTargetException
{
switch (operationID)
{
case PivotPackage.CALL_EXP___ALL_OWNED_ELEMENTS:
return allOwnedElements();
case PivotPackage.CALL_EXP___GET_VALUE__TYPE_STRING:
return getValue((Type)arguments.get(0), (String)arguments.get(1));
case PivotPackage.CALL_EXP___COMPATIBLE_BODY__VALUESPECIFICATION:
return CompatibleBody((ValueSpecification)arguments.get(0));
case PivotPackage.CALL_EXP___IS_NON_NULL:
return isNonNull();
case PivotPackage.CALL_EXP___IS_NULL:
return isNull();
case PivotPackage.CALL_EXP___VALIDATE_TYPE_IS_NOT_NULL__DIAGNOSTICCHAIN_MAP:
return validateTypeIsNotNull((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1));
case PivotPackage.CALL_EXP___VALIDATE_TYPE_IS_NOT_INVALID__DIAGNOSTICCHAIN_MAP:
return validateTypeIsNotInvalid((DiagnosticChain)arguments.get(0), (Map<Object, Object>)arguments.get(1));
}
return eDynamicInvoke(operationID, arguments);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String toString()
{
return super.toString();
}
@Override
public <R> R accept(@NonNull Visitor<R> visitor) {
return visitor.visitCallExp(this);
}
} //CallExpImpl