blob: 172892ed138d8fb8ae17b137425bdf0cd3579d88 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation 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 Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jem.internal.instantiation.impl;
/*
* $RCSfile: PTInstanceofImpl.java,v $
* $Revision: 1.3 $ $Date: 2005/08/24 20:20:24 $
*/
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.jem.internal.instantiation.*;
import org.eclipse.jem.internal.instantiation.PTExpression;
import org.eclipse.jem.internal.instantiation.PTInstanceof;
import org.eclipse.jem.internal.instantiation.InstantiationPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Instanceof</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link org.eclipse.jem.internal.instantiation.impl.PTInstanceofImpl#getOperand <em>Operand</em>}</li>
* <li>{@link org.eclipse.jem.internal.instantiation.impl.PTInstanceofImpl#getType <em>Type</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class PTInstanceofImpl extends PTExpressionImpl implements PTInstanceof {
/**
* The cached value of the '{@link #getOperand() <em>Operand</em>}' containment reference.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOperand()
* @generated
* @ordered
*/
protected PTExpression operand = null;
/**
* The default value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected static final String TYPE_EDEFAULT = null;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getType()
* @generated
* @ordered
*/
protected String type = TYPE_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected PTInstanceofImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected EClass eStaticClass() {
return InstantiationPackage.eINSTANCE.getPTInstanceof();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public PTExpression getOperand() {
return operand;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOperand(PTExpression newOperand, NotificationChain msgs) {
PTExpression oldOperand = operand;
operand = newOperand;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_INSTANCEOF__OPERAND, oldOperand, newOperand);
if (msgs == null) msgs = notification; else msgs.add(notification);
}
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOperand(PTExpression newOperand) {
if (newOperand != operand) {
NotificationChain msgs = null;
if (operand != null)
msgs = ((InternalEObject)operand).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - InstantiationPackage.PT_INSTANCEOF__OPERAND, null, msgs);
if (newOperand != null)
msgs = ((InternalEObject)newOperand).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - InstantiationPackage.PT_INSTANCEOF__OPERAND, null, msgs);
msgs = basicSetOperand(newOperand, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_INSTANCEOF__OPERAND, newOperand, newOperand));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getType() {
return type;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setType(String newType) {
String oldType = type;
type = newType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, InstantiationPackage.PT_INSTANCEOF__TYPE, oldType, type));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) {
if (featureID >= 0) {
switch (eDerivedStructuralFeatureID(featureID, baseClass)) {
case InstantiationPackage.PT_INSTANCEOF__OPERAND:
return basicSetOperand(null, msgs);
default:
return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs);
}
}
return eBasicSetContainer(null, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Object eGet(EStructuralFeature eFeature, boolean resolve) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_INSTANCEOF__OPERAND:
return getOperand();
case InstantiationPackage.PT_INSTANCEOF__TYPE:
return getType();
}
return eDynamicGet(eFeature, resolve);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eSet(EStructuralFeature eFeature, Object newValue) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_INSTANCEOF__OPERAND:
setOperand((PTExpression)newValue);
return;
case InstantiationPackage.PT_INSTANCEOF__TYPE:
setType((String)newValue);
return;
}
eDynamicSet(eFeature, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void eUnset(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_INSTANCEOF__OPERAND:
setOperand((PTExpression)null);
return;
case InstantiationPackage.PT_INSTANCEOF__TYPE:
setType(TYPE_EDEFAULT);
return;
}
eDynamicUnset(eFeature);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public boolean eIsSet(EStructuralFeature eFeature) {
switch (eDerivedStructuralFeatureID(eFeature)) {
case InstantiationPackage.PT_INSTANCEOF__OPERAND:
return operand != null;
case InstantiationPackage.PT_INSTANCEOF__TYPE:
return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type);
}
return eDynamicIsSet(eFeature);
}
public String toString() {
return super.toString(); // Really want toString to be final at PTExpression, but EMF doesn't allow it.
}
/*
* (non-Javadoc)
* @see org.eclipse.jem.internal.instantiation.impl.ExpressionImpl#accept0(org.eclipse.jem.internal.instantiation.ParseVisitor)
*/
protected void accept0(ParseVisitor visitor) {
boolean visitChildren = visitor.visit(this);
if (visitChildren) {
// visit children in normal left to right reading order
acceptChild(visitor, getOperand());
}
visitor.endVisit(this);
}
} //InstanceofImpl