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