/**
 * 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.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.ContextFeature;
import org.xtext.datavault.datavaultDsl.DatavaultDslPackage;
import org.xtext.datavault.datavaultDsl.Satellite;
import org.xtext.datavault.datavaultDsl.Timestamp;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Satellite</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link org.xtext.datavault.datavaultDsl.impl.SatelliteImpl#getName <em>Name</em>}</li>
 *   <li>{@link org.xtext.datavault.datavaultDsl.impl.SatelliteImpl#getTimestamp <em>Timestamp</em>}</li>
 *   <li>{@link org.xtext.datavault.datavaultDsl.impl.SatelliteImpl#getContextFeatures <em>Context Features</em>}</li>
 * </ul>
 *
 * @generated
 */
public class SatelliteImpl extends SatelliteEntityImpl implements Satellite {
	/**
	 * 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 #getTimestamp() <em>Timestamp</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTimestamp()
	 * @generated
	 * @ordered
	 */
	protected Timestamp timestamp;

	/**
	 * The cached value of the '{@link #getContextFeatures() <em>Context Features</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getContextFeatures()
	 * @generated
	 * @ordered
	 */
	protected EList<ContextFeature> contextFeatures;

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

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Timestamp getTimestamp() {
		return timestamp;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTimestamp(Timestamp newTimestamp, NotificationChain msgs) {
		Timestamp oldTimestamp = timestamp;
		timestamp = newTimestamp;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DatavaultDslPackage.SATELLITE__TIMESTAMP, oldTimestamp, newTimestamp);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTimestamp(Timestamp newTimestamp) {
		if (newTimestamp != timestamp) {
			NotificationChain msgs = null;
			if (timestamp != null)
				msgs = ((InternalEObject)timestamp).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DatavaultDslPackage.SATELLITE__TIMESTAMP, null, msgs);
			if (newTimestamp != null)
				msgs = ((InternalEObject)newTimestamp).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DatavaultDslPackage.SATELLITE__TIMESTAMP, null, msgs);
			msgs = basicSetTimestamp(newTimestamp, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DatavaultDslPackage.SATELLITE__TIMESTAMP, newTimestamp, newTimestamp));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ContextFeature> getContextFeatures() {
		if (contextFeatures == null) {
			contextFeatures = new EObjectContainmentEList<ContextFeature>(ContextFeature.class, this, DatavaultDslPackage.SATELLITE__CONTEXT_FEATURES);
		}
		return contextFeatures;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DatavaultDslPackage.SATELLITE__TIMESTAMP:
				return basicSetTimestamp(null, msgs);
			case DatavaultDslPackage.SATELLITE__CONTEXT_FEATURES:
				return ((InternalEList<?>)getContextFeatures()).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.SATELLITE__NAME:
				return getName();
			case DatavaultDslPackage.SATELLITE__TIMESTAMP:
				return getTimestamp();
			case DatavaultDslPackage.SATELLITE__CONTEXT_FEATURES:
				return getContextFeatures();
		}
		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.SATELLITE__NAME:
				setName((String)newValue);
				return;
			case DatavaultDslPackage.SATELLITE__TIMESTAMP:
				setTimestamp((Timestamp)newValue);
				return;
			case DatavaultDslPackage.SATELLITE__CONTEXT_FEATURES:
				getContextFeatures().clear();
				getContextFeatures().addAll((Collection<? extends ContextFeature>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DatavaultDslPackage.SATELLITE__NAME:
				setName(NAME_EDEFAULT);
				return;
			case DatavaultDslPackage.SATELLITE__TIMESTAMP:
				setTimestamp((Timestamp)null);
				return;
			case DatavaultDslPackage.SATELLITE__CONTEXT_FEATURES:
				getContextFeatures().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DatavaultDslPackage.SATELLITE__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case DatavaultDslPackage.SATELLITE__TIMESTAMP:
				return timestamp != null;
			case DatavaultDslPackage.SATELLITE__CONTEXT_FEATURES:
				return contextFeatures != null && !contextFeatures.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();
	}

} //SatelliteImpl
