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

org.eclipse.ocl.expressions.impl.VariableImpl 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: VariableImpl.java,v 1.10 2009/01/23 17:16:04 cdamus Exp $
 */
package org.eclipse.ocl.expressions.impl;

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.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.impl.EObjectImpl;
import org.eclipse.ocl.expressions.ExpressionsPackage;
import org.eclipse.ocl.expressions.OCLExpression;
import org.eclipse.ocl.expressions.Variable;
import org.eclipse.ocl.expressions.operations.VariableOperations;
import org.eclipse.ocl.util.ToStringVisitor;
import org.eclipse.ocl.utilities.ASTNode;
import org.eclipse.ocl.utilities.TypedASTNode;
import org.eclipse.ocl.utilities.UtilitiesPackage;
import org.eclipse.ocl.utilities.Visitable;
import org.eclipse.ocl.utilities.Visitor;

/**
 * 
 * An implementation of the model object 'Variable'.
 * 
 * 

* The following features are implemented: *

    *
  • {@link org.eclipse.ocl.expressions.impl.VariableImpl#getStartPosition Start Position}
  • *
  • {@link org.eclipse.ocl.expressions.impl.VariableImpl#getEndPosition End Position}
  • *
  • {@link org.eclipse.ocl.expressions.impl.VariableImpl#getTypeStartPosition Type Start Position}
  • *
  • {@link org.eclipse.ocl.expressions.impl.VariableImpl#getTypeEndPosition Type End Position}
  • *
  • {@link org.eclipse.ocl.expressions.impl.VariableImpl#getInitExpression Init Expression}
  • *
  • {@link org.eclipse.ocl.expressions.impl.VariableImpl#getRepresentedParameter Represented Parameter}
  • *
*

* * @generated */ public class VariableImpl extends EObjectImpl implements Variable { /** * The default value of the '{@link #getStartPosition() Start Position}' attribute. * * * @see #getStartPosition() * @generated * @ordered */ protected static final int START_POSITION_EDEFAULT = -1; /** * The cached value of the '{@link #getStartPosition() Start Position}' attribute. * * * @see #getStartPosition() * @generated * @ordered */ protected int startPosition = START_POSITION_EDEFAULT; /** * The default value of the '{@link #getEndPosition() End Position}' attribute. * * * @see #getEndPosition() * @generated * @ordered */ protected static final int END_POSITION_EDEFAULT = -1; /** * The cached value of the '{@link #getEndPosition() End Position}' attribute. * * * @see #getEndPosition() * @generated * @ordered */ protected int endPosition = END_POSITION_EDEFAULT; /** * The default value of the '{@link #getTypeStartPosition() Type Start Position}' attribute. * * * @see #getTypeStartPosition() * @generated * @ordered */ protected static final int TYPE_START_POSITION_EDEFAULT = -1; /** * The cached value of the '{@link #getTypeStartPosition() Type Start Position}' attribute. * * * @see #getTypeStartPosition() * @generated * @ordered */ protected int typeStartPosition = TYPE_START_POSITION_EDEFAULT; /** * The default value of the '{@link #getTypeEndPosition() Type End Position}' attribute. * * * @see #getTypeEndPosition() * @generated * @ordered */ protected static final int TYPE_END_POSITION_EDEFAULT = -1; /** * The cached value of the '{@link #getTypeEndPosition() Type End Position}' attribute. * * * @see #getTypeEndPosition() * @generated * @ordered */ protected int typeEndPosition = TYPE_END_POSITION_EDEFAULT; /** * The cached value of the '{@link #getInitExpression() Init Expression}' containment reference. * * * @see #getInitExpression() * @generated * @ordered */ protected OCLExpression initExpression; /** * The cached value of the '{@link #getRepresentedParameter() Represented Parameter}' reference. * * * @see #getRepresentedParameter() * @generated * @ordered */ protected PM representedParameter; private String name; private C type; /** * * * @generated */ protected VariableImpl() { super(); } /** * * * @generated */ @Override protected EClass eStaticClass() { return ExpressionsPackage.Literals.VARIABLE; } /** * * * @generated NOT */ public String getName() { return name; } /** * * * @generated NOT */ public C getType() { return type; } /** * * * @generated NOT */ public void setName(String name) { this.name = name; } /** * * * @generated NOT */ public void setType(C type) { this.type = type; } /** * * * @generated */ public int getStartPosition() { return startPosition; } /** * * * @generated */ public void setStartPosition(int newStartPosition) { int oldStartPosition = startPosition; startPosition = newStartPosition; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__START_POSITION, oldStartPosition, startPosition)); } /** * * * @generated */ public int getEndPosition() { return endPosition; } /** * * * @generated */ public void setEndPosition(int newEndPosition) { int oldEndPosition = endPosition; endPosition = newEndPosition; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__END_POSITION, oldEndPosition, endPosition)); } /** * * * @generated */ public int getTypeStartPosition() { return typeStartPosition; } /** * * * @generated */ public void setTypeStartPosition(int newTypeStartPosition) { int oldTypeStartPosition = typeStartPosition; typeStartPosition = newTypeStartPosition; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__TYPE_START_POSITION, oldTypeStartPosition, typeStartPosition)); } /** * * * @generated */ public int getTypeEndPosition() { return typeEndPosition; } /** * * * @generated */ public void setTypeEndPosition(int newTypeEndPosition) { int oldTypeEndPosition = typeEndPosition; typeEndPosition = newTypeEndPosition; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__TYPE_END_POSITION, oldTypeEndPosition, typeEndPosition)); } /** * * * @generated */ public OCLExpression getInitExpression() { return initExpression; } /** * * * @generated */ public NotificationChain basicSetInitExpression( OCLExpression newInitExpression, NotificationChain msgs) { OCLExpression oldInitExpression = initExpression; initExpression = newInitExpression; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__INIT_EXPRESSION, oldInitExpression, newInitExpression); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * * * @generated */ public void setInitExpression(OCLExpression newInitExpression) { if (newInitExpression != initExpression) { NotificationChain msgs = null; if (initExpression != null) msgs = ((InternalEObject) initExpression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ExpressionsPackage.VARIABLE__INIT_EXPRESSION, null, msgs); if (newInitExpression != null) msgs = ((InternalEObject) newInitExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ExpressionsPackage.VARIABLE__INIT_EXPRESSION, null, msgs); msgs = basicSetInitExpression(newInitExpression, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__INIT_EXPRESSION, newInitExpression, newInitExpression)); } /** * * * @generated */ @SuppressWarnings("unchecked") public PM getRepresentedParameter() { if (representedParameter != null && ((EObject) representedParameter).eIsProxy()) { InternalEObject oldRepresentedParameter = (InternalEObject) representedParameter; representedParameter = (PM) eResolveProxy(oldRepresentedParameter); if (representedParameter != oldRepresentedParameter) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, ExpressionsPackage.VARIABLE__REPRESENTED_PARAMETER, oldRepresentedParameter, representedParameter)); } } return representedParameter; } /** * * * @generated */ public PM basicGetRepresentedParameter() { return representedParameter; } /** * * * @generated */ public void setRepresentedParameter(PM newRepresentedParameter) { PM oldRepresentedParameter = representedParameter; representedParameter = newRepresentedParameter; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ExpressionsPackage.VARIABLE__REPRESENTED_PARAMETER, oldRepresentedParameter, representedParameter)); } /** * * * @generated NOT */ @SuppressWarnings("unchecked") public > T accept(U v) { return ((Visitor) v).visitVariable(this); } /** * * * @generated */ public boolean checkInitType(DiagnosticChain diagnostics, Map context) { return VariableOperations.checkInitType(this, diagnostics, context); } /** * * * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case ExpressionsPackage.VARIABLE__INIT_EXPRESSION : return basicSetInitExpression(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * * * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case ExpressionsPackage.VARIABLE__START_POSITION : return getStartPosition(); case ExpressionsPackage.VARIABLE__END_POSITION : return getEndPosition(); case ExpressionsPackage.VARIABLE__TYPE_START_POSITION : return getTypeStartPosition(); case ExpressionsPackage.VARIABLE__TYPE_END_POSITION : return getTypeEndPosition(); case ExpressionsPackage.VARIABLE__INIT_EXPRESSION : return getInitExpression(); case ExpressionsPackage.VARIABLE__REPRESENTED_PARAMETER : if (resolve) return getRepresentedParameter(); return basicGetRepresentedParameter(); } return super.eGet(featureID, resolve, coreType); } /** * * * @generated */ @SuppressWarnings("unchecked") @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case ExpressionsPackage.VARIABLE__START_POSITION : setStartPosition((Integer) newValue); return; case ExpressionsPackage.VARIABLE__END_POSITION : setEndPosition((Integer) newValue); return; case ExpressionsPackage.VARIABLE__TYPE_START_POSITION : setTypeStartPosition((Integer) newValue); return; case ExpressionsPackage.VARIABLE__TYPE_END_POSITION : setTypeEndPosition((Integer) newValue); return; case ExpressionsPackage.VARIABLE__INIT_EXPRESSION : setInitExpression((OCLExpression) newValue); return; case ExpressionsPackage.VARIABLE__REPRESENTED_PARAMETER : setRepresentedParameter((PM) newValue); return; } super.eSet(featureID, newValue); } /** * * * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case ExpressionsPackage.VARIABLE__START_POSITION : setStartPosition(START_POSITION_EDEFAULT); return; case ExpressionsPackage.VARIABLE__END_POSITION : setEndPosition(END_POSITION_EDEFAULT); return; case ExpressionsPackage.VARIABLE__TYPE_START_POSITION : setTypeStartPosition(TYPE_START_POSITION_EDEFAULT); return; case ExpressionsPackage.VARIABLE__TYPE_END_POSITION : setTypeEndPosition(TYPE_END_POSITION_EDEFAULT); return; case ExpressionsPackage.VARIABLE__INIT_EXPRESSION : setInitExpression((OCLExpression) null); return; case ExpressionsPackage.VARIABLE__REPRESENTED_PARAMETER : setRepresentedParameter((PM) null); return; } super.eUnset(featureID); } /** * * * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case ExpressionsPackage.VARIABLE__START_POSITION : return startPosition != START_POSITION_EDEFAULT; case ExpressionsPackage.VARIABLE__END_POSITION : return endPosition != END_POSITION_EDEFAULT; case ExpressionsPackage.VARIABLE__TYPE_START_POSITION : return typeStartPosition != TYPE_START_POSITION_EDEFAULT; case ExpressionsPackage.VARIABLE__TYPE_END_POSITION : return typeEndPosition != TYPE_END_POSITION_EDEFAULT; case ExpressionsPackage.VARIABLE__INIT_EXPRESSION : return initExpression != null; case ExpressionsPackage.VARIABLE__REPRESENTED_PARAMETER : return representedParameter != null; } return super.eIsSet(featureID); } /** * * * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) { if (baseClass == Visitable.class) { switch (derivedFeatureID) { default : return -1; } } if (baseClass == ASTNode.class) { switch (derivedFeatureID) { case ExpressionsPackage.VARIABLE__START_POSITION : return UtilitiesPackage.AST_NODE__START_POSITION; case ExpressionsPackage.VARIABLE__END_POSITION : return UtilitiesPackage.AST_NODE__END_POSITION; default : return -1; } } if (baseClass == TypedASTNode.class) { switch (derivedFeatureID) { case ExpressionsPackage.VARIABLE__TYPE_START_POSITION : return UtilitiesPackage.TYPED_AST_NODE__TYPE_START_POSITION; case ExpressionsPackage.VARIABLE__TYPE_END_POSITION : return UtilitiesPackage.TYPED_AST_NODE__TYPE_END_POSITION; default : return -1; } } return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); } /** * * * @generated */ @Override public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) { if (baseClass == Visitable.class) { switch (baseFeatureID) { default : return -1; } } if (baseClass == ASTNode.class) { switch (baseFeatureID) { case UtilitiesPackage.AST_NODE__START_POSITION : return ExpressionsPackage.VARIABLE__START_POSITION; case UtilitiesPackage.AST_NODE__END_POSITION : return ExpressionsPackage.VARIABLE__END_POSITION; default : return -1; } } if (baseClass == TypedASTNode.class) { switch (baseFeatureID) { case UtilitiesPackage.TYPED_AST_NODE__TYPE_START_POSITION : return ExpressionsPackage.VARIABLE__TYPE_START_POSITION; case UtilitiesPackage.TYPED_AST_NODE__TYPE_END_POSITION : return ExpressionsPackage.VARIABLE__TYPE_END_POSITION; default : return -1; } } return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } /** * * * @generated NOT */ @Override public String toString() { if (eIsProxy()) { return super.toString(); } return accept(ToStringVisitor.getInstance(this)); } } //VariableImpl




© 2015 - 2024 Weber Informatics LLC | Privacy Policy