/**
 * generated by Xtext 2.9.0
 */
package org.xtext.datavault.datavaultDsl.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.EObject;
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.xtext.datavault.datavaultDsl.DatavaultDslPackage;
import org.xtext.datavault.datavaultDsl.Node;
import org.xtext.datavault.datavaultDsl.SatelliteReference;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Node</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.xtext.datavault.datavaultDsl.impl.NodeImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.xtext.datavault.datavaultDsl.impl.NodeImpl#getFeaturesKeys <em>Features Keys</em>}</li>
 *   <li>{@link org.xtext.datavault.datavaultDsl.impl.NodeImpl#getSatelliteReferences <em>Satellite References</em>}</li>
 * </ul>
 *
 * @generated
 */
public class NodeImpl extends NodeEntityImpl implements Node {
	/**
	 * 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 #getFeaturesKeys() <em>Features Keys</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFeaturesKeys()
	 * @generated
	 * @ordered
	 */
	protected EList<EObject> featuresKeys;

	/**
	 * The cached value of the '{@link #getSatelliteReferences() <em>Satellite References</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSatelliteReferences()
	 * @generated
	 * @ordered
	 */
	protected EList<SatelliteReference> satelliteReferences;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected NodeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DatavaultDslPackage.Literals.NODE;
	}

	/**
	 * <!-- 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, DatavaultDslPackage.NODE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EObject> getFeaturesKeys() {
		if (featuresKeys == null) {
			featuresKeys = new EObjectContainmentEList<EObject>(EObject.class, this, DatavaultDslPackage.NODE__FEATURES_KEYS);
		}
		return featuresKeys;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SatelliteReference> getSatelliteReferences() {
		if (satelliteReferences == null) {
			satelliteReferences = new EObjectContainmentEList<SatelliteReference>(SatelliteReference.class, this, DatavaultDslPackage.NODE__SATELLITE_REFERENCES);
		}
		return satelliteReferences;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DatavaultDslPackage.NODE__FEATURES_KEYS:
				return ((InternalEList<?>)getFeaturesKeys()).basicRemove(otherEnd, msgs);
			case DatavaultDslPackage.NODE__SATELLITE_REFERENCES:
				return ((InternalEList<?>)getSatelliteReferences()).basicRemove(otherEnd, 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 DatavaultDslPackage.NODE__NAME:
				return getName();
			case DatavaultDslPackage.NODE__FEATURES_KEYS:
				return getFeaturesKeys();
			case DatavaultDslPackage.NODE__SATELLITE_REFERENCES:
				return getSatelliteReferences();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DatavaultDslPackage.NODE__NAME:
				setName((String)newValue);
				return;
			case DatavaultDslPackage.NODE__FEATURES_KEYS:
				getFeaturesKeys().clear();
				getFeaturesKeys().addAll((Collection<? extends EObject>)newValue);
				return;
			case DatavaultDslPackage.NODE__SATELLITE_REFERENCES:
				getSatelliteReferences().clear();
				getSatelliteReferences().addAll((Collection<? extends SatelliteReference>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DatavaultDslPackage.NODE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case DatavaultDslPackage.NODE__FEATURES_KEYS:
				getFeaturesKeys().clear();
				return;
			case DatavaultDslPackage.NODE__SATELLITE_REFERENCES:
				getSatelliteReferences().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DatavaultDslPackage.NODE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case DatavaultDslPackage.NODE__FEATURES_KEYS:
				return featuresKeys != null && !featuresKeys.isEmpty();
			case DatavaultDslPackage.NODE__SATELLITE_REFERENCES:
				return satelliteReferences != null && !satelliteReferences.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- 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();
	}

} //NodeImpl
