/**
*/
package org.erlide.erlang.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.erlide.erlang.ErlangPackage;
import org.erlide.erlang.Expression;
import org.erlide.erlang.RecordFieldDef;
import org.erlide.erlang.TopType;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Record Field Def</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.erlide.erlang.impl.RecordFieldDefImpl#getName <em>Name</em>}</li>
* <li>{@link org.erlide.erlang.impl.RecordFieldDefImpl#getValue <em>Value</em>}
* </li>
* <li>{@link org.erlide.erlang.impl.RecordFieldDefImpl#getType <em>Type</em>}</li>
* </ul>
*
* @generated
*/
public class RecordFieldDefImpl extends AtomRefTargetImpl implements
RecordFieldDef {
/**
* 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 #getValue() <em>Value</em>}' containment
* reference. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getValue()
* @generated
* @ordered
*/
protected Expression value;
/**
* The cached value of the '{@link #getType() <em>Type</em>}' containment
* reference. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getType()
* @generated
* @ordered
*/
protected TopType type;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected RecordFieldDefImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ErlangPackage.Literals.RECORD_FIELD_DEF;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String getName() {
return name;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setName(final String newName) {
final String oldName = name;
name = newName;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET,
ErlangPackage.RECORD_FIELD_DEF__NAME, oldName, name));
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Expression getValue() {
return value;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetValue(final Expression newValue,
NotificationChain msgs) {
final Expression oldValue = value;
value = newValue;
if (eNotificationRequired()) {
final ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, ErlangPackage.RECORD_FIELD_DEF__VALUE,
oldValue, newValue);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setValue(final Expression newValue) {
if (newValue != value) {
NotificationChain msgs = null;
if (value != null) {
msgs = ((InternalEObject) value).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE
- ErlangPackage.RECORD_FIELD_DEF__VALUE, null,
msgs);
}
if (newValue != null) {
msgs = ((InternalEObject) newValue).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- ErlangPackage.RECORD_FIELD_DEF__VALUE, null,
msgs);
}
msgs = basicSetValue(newValue, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET,
ErlangPackage.RECORD_FIELD_DEF__VALUE, newValue, newValue));
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public TopType getType() {
return type;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetType(final TopType newType,
NotificationChain msgs) {
final TopType oldType = type;
type = newType;
if (eNotificationRequired()) {
final ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, ErlangPackage.RECORD_FIELD_DEF__TYPE,
oldType, newType);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setType(final TopType newType) {
if (newType != type) {
NotificationChain msgs = null;
if (type != null) {
msgs = ((InternalEObject) type).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE
- ErlangPackage.RECORD_FIELD_DEF__TYPE, null,
msgs);
}
if (newType != null) {
msgs = ((InternalEObject) newType).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- ErlangPackage.RECORD_FIELD_DEF__TYPE, null,
msgs);
}
msgs = basicSetType(newType, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET,
ErlangPackage.RECORD_FIELD_DEF__TYPE, newType, newType));
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(final InternalEObject otherEnd,
final int featureID, final NotificationChain msgs) {
switch (featureID) {
case ErlangPackage.RECORD_FIELD_DEF__VALUE:
return basicSetValue(null, msgs);
case ErlangPackage.RECORD_FIELD_DEF__TYPE:
return basicSetType(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Object eGet(final int featureID, final boolean resolve,
final boolean coreType) {
switch (featureID) {
case ErlangPackage.RECORD_FIELD_DEF__NAME:
return getName();
case ErlangPackage.RECORD_FIELD_DEF__VALUE:
return getValue();
case ErlangPackage.RECORD_FIELD_DEF__TYPE:
return getType();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eSet(final int featureID, final Object newValue) {
switch (featureID) {
case ErlangPackage.RECORD_FIELD_DEF__NAME:
setName((String) newValue);
return;
case ErlangPackage.RECORD_FIELD_DEF__VALUE:
setValue((Expression) newValue);
return;
case ErlangPackage.RECORD_FIELD_DEF__TYPE:
setType((TopType) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(final int featureID) {
switch (featureID) {
case ErlangPackage.RECORD_FIELD_DEF__NAME:
setName(NAME_EDEFAULT);
return;
case ErlangPackage.RECORD_FIELD_DEF__VALUE:
setValue((Expression) null);
return;
case ErlangPackage.RECORD_FIELD_DEF__TYPE:
setType((TopType) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(final int featureID) {
switch (featureID) {
case ErlangPackage.RECORD_FIELD_DEF__NAME:
return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT
.equals(name);
case ErlangPackage.RECORD_FIELD_DEF__VALUE:
return value != null;
case ErlangPackage.RECORD_FIELD_DEF__TYPE:
return type != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) {
return super.toString();
}
final StringBuffer result = new StringBuffer(super.toString());
result.append(" (name: ");
result.append(name);
result.append(')');
return result.toString();
}
} // RecordFieldDefImpl