All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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 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 context) { return OperationCallExpOperations.checkArgumentsConform(this, diagnostics, context); } /** * * * @generated */ public boolean checkArgumentCount(DiagnosticChain diagnostics, Map context) { return OperationCallExpOperations.checkArgumentCount(this, diagnostics, context); } /** * * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ExpressionsPackage.OPERATION_CALL_EXP__ARGUMENT : return ((InternalEList) getArgument()).basicRemove(otherEnd, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case ExpressionsPackage.OPERATION_CALL_EXP__ARGUMENT : return getArgument(); case ExpressionsPackage.OPERATION_CALL_EXP__REFERRED_OPERATION : if (resolve) return getReferredOperation(); return basicGetReferredOperation(); case ExpressionsPackage.OPERATION_CALL_EXP__OPERATION_CODE : return getOperationCode(); } return super.eGet(featureID, resolve, coreType); } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ExpressionsPackage.OPERATION_CALL_EXP__ARGUMENT : getArgument().clear(); getArgument().addAll( (Collection>) newValue); return; case ExpressionsPackage.OPERATION_CALL_EXP__REFERRED_OPERATION : setReferredOperation((O) newValue); return; case ExpressionsPackage.OPERATION_CALL_EXP__OPERATION_CODE : setOperationCode((Integer) newValue); return; } super.eSet(featureID, newValue); } /** * * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ExpressionsPackage.OPERATION_CALL_EXP__ARGUMENT : getArgument().clear(); return; case ExpressionsPackage.OPERATION_CALL_EXP__REFERRED_OPERATION : setReferredOperation((O) null); return; case ExpressionsPackage.OPERATION_CALL_EXP__OPERATION_CODE : setOperationCode(OPERATION_CODE_EDEFAULT); return; } super.eUnset(featureID); } /** * * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ExpressionsPackage.OPERATION_CALL_EXP__ARGUMENT : return argument != null && !argument.isEmpty(); case ExpressionsPackage.OPERATION_CALL_EXP__REFERRED_OPERATION : return referredOperation != null; case ExpressionsPackage.OPERATION_CALL_EXP__OPERATION_CODE : return getOperationCode() != OPERATION_CODE_EDEFAULT; } return super.eIsSet(featureID); } /** * @generated NOT */ @Override @SuppressWarnings("unchecked") public > T accept(U v) { return ((Visitor) v) .visitOperationCallExp(this); } } //OperationCallExpImpl




© 2015 - 2024 Weber Informatics LLC | Privacy Policy