/** */ package org.example.smalljava.smallJava.impl; 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.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.example.smalljava.smallJava.SJClass; import org.example.smalljava.smallJava.SJExpression; import org.example.smalljava.smallJava.SJSymbol; import org.example.smalljava.smallJava.SJVariableDeclaration; import org.example.smalljava.smallJava.SmallJavaPackage; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>SJ Variable Declaration</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * <ul> * <li>{@link org.example.smalljava.smallJava.impl.SJVariableDeclarationImpl#getType <em>Type</em>}</li> * <li>{@link org.example.smalljava.smallJava.impl.SJVariableDeclarationImpl#getName <em>Name</em>}</li> * <li>{@link org.example.smalljava.smallJava.impl.SJVariableDeclarationImpl#getExpression <em>Expression</em>}</li> * </ul> * </p> * * @generated */ public class SJVariableDeclarationImpl extends SJStatementImpl implements SJVariableDeclaration { /** * The cached value of the '{@link #getType() <em>Type</em>}' reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getType() * @generated * @ordered */ protected SJClass type; /** * The default value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected static final String NAME_EDEFAULT = null; /** * The cached value of the '{@link #getName() <em>Name</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getName() * @generated * @ordered */ protected String name = NAME_EDEFAULT; /** * The cached value of the '{@link #getExpression() <em>Expression</em>}' containment reference. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getExpression() * @generated * @ordered */ protected SJExpression expression; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected SJVariableDeclarationImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return SmallJavaPackage.Literals.SJ_VARIABLE_DECLARATION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public SJClass getType() { if (type != null && type.eIsProxy()) { InternalEObject oldType = (InternalEObject)type; type = (SJClass)eResolveProxy(oldType); if (type != oldType) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE, oldType, type)); } } return type; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public SJClass basicGetType() { return type; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setType(SJClass newType) { SJClass oldType = type; type = newType; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE, oldType, type)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getName() { return name; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setName(String newName) { String oldName = name; name = newName; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME, oldName, name)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public SJExpression getExpression() { return expression; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public NotificationChain basicSetExpression(SJExpression newExpression, NotificationChain msgs) { SJExpression oldExpression = expression; expression = newExpression; if (eNotificationRequired()) { ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION, oldExpression, newExpression); if (msgs == null) msgs = notification; else msgs.add(notification); } return msgs; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setExpression(SJExpression newExpression) { if (newExpression != expression) { NotificationChain msgs = null; if (expression != null) msgs = ((InternalEObject)expression).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION, null, msgs); if (newExpression != null) msgs = ((InternalEObject)newExpression).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION, null, msgs); msgs = basicSetExpression(newExpression, msgs); if (msgs != null) msgs.dispatch(); } else if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION, newExpression, newExpression)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { switch (featureID) { case SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION: return basicSetExpression(null, msgs); } return super.eInverseRemove(otherEnd, featureID, msgs); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE: if (resolve) return getType(); return basicGetType(); case SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME: return getName(); case SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION: return getExpression(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE: setType((SJClass)newValue); return; case SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME: setName((String)newValue); return; case SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION: setExpression((SJExpression)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE: setType((SJClass)null); return; case SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME: setName(NAME_EDEFAULT); return; case SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION: setExpression((SJExpression)null); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE: return type != null; case SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME: return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); case SmallJavaPackage.SJ_VARIABLE_DECLARATION__EXPRESSION: return expression != null; } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eBaseStructuralFeatureID(int derivedFeatureID, Class<?> baseClass) { if (baseClass == SJSymbol.class) { switch (derivedFeatureID) { case SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE: return SmallJavaPackage.SJ_SYMBOL__TYPE; case SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME: return SmallJavaPackage.SJ_SYMBOL__NAME; default: return -1; } } return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public int eDerivedStructuralFeatureID(int baseFeatureID, Class<?> baseClass) { if (baseClass == SJSymbol.class) { switch (baseFeatureID) { case SmallJavaPackage.SJ_SYMBOL__TYPE: return SmallJavaPackage.SJ_VARIABLE_DECLARATION__TYPE; case SmallJavaPackage.SJ_SYMBOL__NAME: return SmallJavaPackage.SJ_VARIABLE_DECLARATION__NAME; default: return -1; } } return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (name: "); result.append(name); result.append(')'); return result.toString(); } } //SJVariableDeclarationImpl