/**
*/
package org.erlide.erlang.impl;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.erlide.erlang.DefineAttribute;
import org.erlide.erlang.ErlangPackage;
import org.erlide.erlang.Expression;
import org.erlide.erlang.Guard;
/**
* <!-- begin-user-doc --> An implementation of the model object '
* <em><b>Define Attribute</b></em>'. <!-- end-user-doc -->
* <p>
* The following features are implemented:
* </p>
* <ul>
* <li>{@link org.erlide.erlang.impl.DefineAttributeImpl#getMacroName <em>Macro
* Name</em>}</li>
* <li>{@link org.erlide.erlang.impl.DefineAttributeImpl#getArgs <em>Args</em>}</li>
* <li>{@link org.erlide.erlang.impl.DefineAttributeImpl#getValue <em>Value
* </em>}</li>
* </ul>
*
* @generated
*/
public class DefineAttributeImpl extends AbstractDefineAttributeImpl implements
DefineAttribute {
/**
* The default value of the '{@link #getMacroName() <em>Macro Name</em>}'
* attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getMacroName()
* @generated
* @ordered
*/
protected static final String MACRO_NAME_EDEFAULT = null;
/**
* The cached value of the '{@link #getMacroName() <em>Macro Name</em>}'
* attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getMacroName()
* @generated
* @ordered
*/
protected String macroName = MACRO_NAME_EDEFAULT;
/**
* The cached value of the '{@link #getArgs() <em>Args</em>}' containment
* reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getArgs()
* @generated
* @ordered
*/
protected EList<Expression> args;
/**
* The cached value of the '{@link #getValue() <em>Value</em>}' containment
* reference. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @see #getValue()
* @generated
* @ordered
*/
protected Guard value;
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
protected DefineAttributeImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
protected EClass eStaticClass() {
return ErlangPackage.Literals.DEFINE_ATTRIBUTE;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String getMacroName() {
return macroName;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void setMacroName(final String newMacroName) {
final String oldMacroName = macroName;
macroName = newMacroName;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET,
ErlangPackage.DEFINE_ATTRIBUTE__MACRO_NAME, oldMacroName,
macroName));
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public EList<Expression> getArgs() {
if (args == null) {
args = new EObjectContainmentEList<Expression>(Expression.class,
this, ErlangPackage.DEFINE_ATTRIBUTE__ARGS);
}
return args;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public Guard getValue() {
return value;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public NotificationChain basicSetValue(final Guard newValue,
NotificationChain msgs) {
final Guard oldValue = value;
value = newValue;
if (eNotificationRequired()) {
final ENotificationImpl notification = new ENotificationImpl(this,
Notification.SET, ErlangPackage.DEFINE_ATTRIBUTE__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 Guard newValue) {
if (newValue != value) {
NotificationChain msgs = null;
if (value != null) {
msgs = ((InternalEObject) value).eInverseRemove(this,
EOPPOSITE_FEATURE_BASE
- ErlangPackage.DEFINE_ATTRIBUTE__VALUE, null,
msgs);
}
if (newValue != null) {
msgs = ((InternalEObject) newValue).eInverseAdd(this,
EOPPOSITE_FEATURE_BASE
- ErlangPackage.DEFINE_ATTRIBUTE__VALUE, null,
msgs);
}
msgs = basicSetValue(newValue, msgs);
if (msgs != null) {
msgs.dispatch();
}
} else if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET,
ErlangPackage.DEFINE_ATTRIBUTE__VALUE, newValue, newValue));
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public NotificationChain eInverseRemove(final InternalEObject otherEnd,
final int featureID, final NotificationChain msgs) {
switch (featureID) {
case ErlangPackage.DEFINE_ATTRIBUTE__ARGS:
return ((InternalEList<?>) getArgs()).basicRemove(otherEnd, msgs);
case ErlangPackage.DEFINE_ATTRIBUTE__VALUE:
return basicSetValue(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.DEFINE_ATTRIBUTE__MACRO_NAME:
return getMacroName();
case ErlangPackage.DEFINE_ATTRIBUTE__ARGS:
return getArgs();
case ErlangPackage.DEFINE_ATTRIBUTE__VALUE:
return getValue();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@SuppressWarnings("unchecked")
@Override
public void eSet(final int featureID, final Object newValue) {
switch (featureID) {
case ErlangPackage.DEFINE_ATTRIBUTE__MACRO_NAME:
setMacroName((String) newValue);
return;
case ErlangPackage.DEFINE_ATTRIBUTE__ARGS:
getArgs().clear();
getArgs().addAll((Collection<? extends Expression>) newValue);
return;
case ErlangPackage.DEFINE_ATTRIBUTE__VALUE:
setValue((Guard) newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public void eUnset(final int featureID) {
switch (featureID) {
case ErlangPackage.DEFINE_ATTRIBUTE__MACRO_NAME:
setMacroName(MACRO_NAME_EDEFAULT);
return;
case ErlangPackage.DEFINE_ATTRIBUTE__ARGS:
getArgs().clear();
return;
case ErlangPackage.DEFINE_ATTRIBUTE__VALUE:
setValue((Guard) null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public boolean eIsSet(final int featureID) {
switch (featureID) {
case ErlangPackage.DEFINE_ATTRIBUTE__MACRO_NAME:
return MACRO_NAME_EDEFAULT == null ? macroName != null
: !MACRO_NAME_EDEFAULT.equals(macroName);
case ErlangPackage.DEFINE_ATTRIBUTE__ARGS:
return args != null && !args.isEmpty();
case ErlangPackage.DEFINE_ATTRIBUTE__VALUE:
return value != 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(" (macroName: ");
result.append(macroName);
result.append(')');
return result.toString();
}
} // DefineAttributeImpl