/**
 */
package myDsl.impl;

import java.util.Collection;

import myDsl.ClassA;
import myDsl.ClassB;
import myDsl.MyDslPackage;

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.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Class A</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link myDsl.impl.ClassAImpl#getName <em>Name</em>}</li>
 *   <li>{@link myDsl.impl.ClassAImpl#getClassb <em>Classb</em>}</li>
 *   <li>{@link myDsl.impl.ClassAImpl#getReferingbs <em>Referingbs</em>}</li>
 * </ul>
 *
 * @generated
 */
public class ClassAImpl extends MinimalEObjectImpl.Container implements ClassA {
	/**
	 * 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 #getClassb() <em>Classb</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClassb()
	 * @generated
	 * @ordered
	 */
	protected EList<ClassB> classb;

	/**
	 * The cached value of the '{@link #getReferingbs() <em>Referingbs</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getReferingbs()
	 * @generated
	 * @ordered
	 */
	protected EList<ClassB> referingbs;

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

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ClassB> getClassb() {
		if (classb == null) {
			classb = new EObjectContainmentWithInverseEList<ClassB>(ClassB.class, this, MyDslPackage.CLASS_A__CLASSB, MyDslPackage.CLASS_B__SOURCE);
		}
		return classb;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<ClassB> getReferingbs() {
		if (referingbs == null) {
			referingbs = new EObjectWithInverseResolvingEList<ClassB>(ClassB.class, this, MyDslPackage.CLASS_A__REFERINGBS, MyDslPackage.CLASS_B__TARGET);
		}
		return referingbs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MyDslPackage.CLASS_A__CLASSB:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getClassb()).basicAdd(otherEnd, msgs);
			case MyDslPackage.CLASS_A__REFERINGBS:
				return ((InternalEList<InternalEObject>)(InternalEList<?>)getReferingbs()).basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MyDslPackage.CLASS_A__CLASSB:
				return ((InternalEList<?>)getClassb()).basicRemove(otherEnd, msgs);
			case MyDslPackage.CLASS_A__REFERINGBS:
				return ((InternalEList<?>)getReferingbs()).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 MyDslPackage.CLASS_A__NAME:
				return getName();
			case MyDslPackage.CLASS_A__CLASSB:
				return getClassb();
			case MyDslPackage.CLASS_A__REFERINGBS:
				return getReferingbs();
		}
		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 MyDslPackage.CLASS_A__NAME:
				setName((String)newValue);
				return;
			case MyDslPackage.CLASS_A__CLASSB:
				getClassb().clear();
				getClassb().addAll((Collection<? extends ClassB>)newValue);
				return;
			case MyDslPackage.CLASS_A__REFERINGBS:
				getReferingbs().clear();
				getReferingbs().addAll((Collection<? extends ClassB>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MyDslPackage.CLASS_A__NAME:
				setName(NAME_EDEFAULT);
				return;
			case MyDslPackage.CLASS_A__CLASSB:
				getClassb().clear();
				return;
			case MyDslPackage.CLASS_A__REFERINGBS:
				getReferingbs().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MyDslPackage.CLASS_A__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case MyDslPackage.CLASS_A__CLASSB:
				return classb != null && !classb.isEmpty();
			case MyDslPackage.CLASS_A__REFERINGBS:
				return referingbs != null && !referingbs.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();
	}

} //ClassAImpl
