/**
 */
package com.irtsaintexupery.pseim.mapping.impl;

import com.irtsaintexupery.pseim.mapping.GraphElementMapping;
import com.irtsaintexupery.pseim.mapping.MappingPackage;

import com.irtsaintexupery.pseim.seim.GraphElement;

import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;

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.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Graph Element Mapping</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.irtsaintexupery.pseim.mapping.impl.GraphElementMappingImpl#getModelGraphElement <em>Model Graph Element</em>}</li>
 *   <li>{@link com.irtsaintexupery.pseim.mapping.impl.GraphElementMappingImpl#getPatternGraphElement <em>Pattern Graph Element</em>}</li>
 * </ul>
 *
 * @generated
 */
public class GraphElementMappingImpl extends MinimalEObjectImpl.Container implements GraphElementMapping {
	/**
	 * The cached value of the '{@link #getModelGraphElement() <em>Model Graph Element</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getModelGraphElement()
	 * @generated
	 * @ordered
	 */
	protected EList<GraphElement> modelGraphElement;

	/**
	 * The cached value of the '{@link #getPatternGraphElement() <em>Pattern Graph Element</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPatternGraphElement()
	 * @generated
	 * @ordered
	 */
	protected GraphElement patternGraphElement;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<GraphElement> getModelGraphElement() {
		if (modelGraphElement == null) {
			modelGraphElement = new EObjectResolvingEList<GraphElement>(GraphElement.class, this, MappingPackage.GRAPH_ELEMENT_MAPPING__MODEL_GRAPH_ELEMENT);
		}
		return modelGraphElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GraphElement getPatternGraphElement() {
		if (patternGraphElement != null && patternGraphElement.eIsProxy()) {
			InternalEObject oldPatternGraphElement = (InternalEObject)patternGraphElement;
			patternGraphElement = (GraphElement)eResolveProxy(oldPatternGraphElement);
			if (patternGraphElement != oldPatternGraphElement) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, MappingPackage.GRAPH_ELEMENT_MAPPING__PATTERN_GRAPH_ELEMENT, oldPatternGraphElement, patternGraphElement));
			}
		}
		return patternGraphElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public GraphElement basicGetPatternGraphElement() {
		return patternGraphElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPatternGraphElement(GraphElement newPatternGraphElement) {
		GraphElement oldPatternGraphElement = patternGraphElement;
		patternGraphElement = newPatternGraphElement;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MappingPackage.GRAPH_ELEMENT_MAPPING__PATTERN_GRAPH_ELEMENT, oldPatternGraphElement, patternGraphElement));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MappingPackage.GRAPH_ELEMENT_MAPPING__MODEL_GRAPH_ELEMENT:
				return getModelGraphElement();
			case MappingPackage.GRAPH_ELEMENT_MAPPING__PATTERN_GRAPH_ELEMENT:
				if (resolve) return getPatternGraphElement();
				return basicGetPatternGraphElement();
		}
		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 MappingPackage.GRAPH_ELEMENT_MAPPING__MODEL_GRAPH_ELEMENT:
				getModelGraphElement().clear();
				getModelGraphElement().addAll((Collection<? extends GraphElement>)newValue);
				return;
			case MappingPackage.GRAPH_ELEMENT_MAPPING__PATTERN_GRAPH_ELEMENT:
				setPatternGraphElement((GraphElement)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MappingPackage.GRAPH_ELEMENT_MAPPING__MODEL_GRAPH_ELEMENT:
				getModelGraphElement().clear();
				return;
			case MappingPackage.GRAPH_ELEMENT_MAPPING__PATTERN_GRAPH_ELEMENT:
				setPatternGraphElement((GraphElement)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MappingPackage.GRAPH_ELEMENT_MAPPING__MODEL_GRAPH_ELEMENT:
				return modelGraphElement != null && !modelGraphElement.isEmpty();
			case MappingPackage.GRAPH_ELEMENT_MAPPING__PATTERN_GRAPH_ELEMENT:
				return patternGraphElement != null;
		}
		return super.eIsSet(featureID);
	}

} //GraphElementMappingImpl
