org.eclipse.ocl.expressions.impl.OperationCallExpImpl Maven / Gradle / Ivy
/**
*
*
* Copyright (c) 2006, 2009 IBM Corporation, Zeligsoft Inc., 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:
* IBM - Initial API and implementation
* Zeligsoft - Bug 207365
*
*
*
* $Id: OperationCallExpImpl.java,v 1.10 2009/06/25 19:23:52 ewillink Exp $
*/
package org.eclipse.ocl.expressions.impl;
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.EObject;
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.InternalEList;
import org.eclipse.ocl.Environment;
import org.eclipse.ocl.expressions.ExpressionsPackage;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.expressions.OperationCallExp;
import org.eclipse.ocl.expressions.operations.OperationCallExpOperations;
import org.eclipse.ocl.util.OCLStandardLibraryUtil;
import org.eclipse.ocl.util.TypeUtil;
import org.eclipse.ocl.utilities.PredefinedType;
import org.eclipse.ocl.utilities.Visitor;
/**
*
* An implementation of the model object 'Operation Call Exp'.
*
*
* The following features are implemented:
*
* - {@link org.eclipse.ocl.expressions.impl.OperationCallExpImpl#getArgument Argument}
* - {@link org.eclipse.ocl.expressions.impl.OperationCallExpImpl#getReferredOperation Referred Operation}
* - {@link org.eclipse.ocl.expressions.impl.OperationCallExpImpl#getOperationCode Operation Code}
*
*
*
* @generated
*/
public class OperationCallExpImpl
extends FeatureCallExpImpl
implements OperationCallExp {
/**
* The cached value of the '{@link #getArgument() Argument}' containment reference list.
*
*
* @see #getArgument()
* @generated
* @ordered
*/
protected EList> argument;
/**
* The cached value of the '{@link #getReferredOperation() Referred Operation}' reference.
*
*
* @see #getReferredOperation()
* @generated
* @ordered
*/
protected O referredOperation;
/**
* The default value of the '{@link #getOperationCode() Operation Code}' attribute.
*
*
* @see #getOperationCode()
* @generated
* @ordered
*/
protected static final int OPERATION_CODE_EDEFAULT = 0;
private int operationCode = -1;
/**
*
*
* @generated
*/
protected OperationCallExpImpl() {
super();
}
/**
*
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ExpressionsPackage.Literals.OPERATION_CALL_EXP;
}
/**
*
*
* @generated
*/
public EList> getArgument() {
if (argument == null) {
argument = new EObjectContainmentEList>(
OCLExpression.class, this,
ExpressionsPackage.OPERATION_CALL_EXP__ARGUMENT);
}
return argument;
}
/**
*
*
* @generated
*/
@SuppressWarnings("unchecked")
public O getReferredOperation() {
if (referredOperation != null
&& ((EObject) referredOperation).eIsProxy()) {
InternalEObject oldReferredOperation = (InternalEObject) referredOperation;
referredOperation = (O) eResolveProxy(oldReferredOperation);
if (referredOperation != oldReferredOperation) {
if (eNotificationRequired())
eNotify(new ENotificationImpl(
this,
Notification.RESOLVE,
ExpressionsPackage.OPERATION_CALL_EXP__REFERRED_OPERATION,
oldReferredOperation, referredOperation));
}
}
return referredOperation;
}
/**
*
*
* @generated
*/
public O basicGetReferredOperation() {
return referredOperation;
}
/**
*
*
* @generated
*/
public void setReferredOperation(O newReferredOperation) {
O oldReferredOperation = referredOperation;
referredOperation = newReferredOperation;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET,
ExpressionsPackage.OPERATION_CALL_EXP__REFERRED_OPERATION,
oldReferredOperation, referredOperation));
}
/**
*
*
* @generated NOT
*/
public int getOperationCode() {
if (operationCode < 0) {
if ((getSource() != null) && (getReferredOperation() != null)) {
Environment, C, O, ?, ?, ?, ?, ?, ?, ?, ?, ?> env = Environment.Registry.INSTANCE
.getEnvironmentFor(getSource());
C type = getSource().getType();
if (env != null) {
String operName = env.getUMLReflection().getName(
getReferredOperation());
if (type instanceof PredefinedType>) {
operationCode = OCLStandardLibraryUtil
.getOperationCode(operName);
} else if (TypeUtil.isOclAnyOperation(env,
getReferredOperation())) {
// not a predefined type? Model types have the AnyType
// operations (except in the case that a model type
// defines the corresponding operation)
operationCode = OCLStandardLibraryUtil
.getOclAnyOperationCode(operName);
}
}
} else {
operationCode = 0;
}
}
return operationCode;
}
/**
*
*
* @generated NOT
*/
public void setOperationCode(int newOperationCode) {
operationCode = newOperationCode;
}
/**
*
*
* @generated
*/
public boolean checkArgumentsConform(DiagnosticChain diagnostics,
Map