/*******************************************************************************
 * Copyright (c) 2015, 2016 CNRS, IRIT, IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the LGPL 3.0
 * which accompanies this distribution, and is available at
 * https://www.gnu.org/licenses/lgpl-3.0-standalone.html
 *
 * Contributors:
 *     Faiez Zalila - initial API and implementation and/or initial documentation
 *******************************************************************************/
/**
 */
package com.irtsaintexupery.fiacre.instance.fiacreinstance.impl;

import java.util.Collection;

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

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import com.irtsaintexupery.fiacre.instance.fiacreinstance.BlockInstance;
import com.irtsaintexupery.fiacre.instance.fiacreinstance.FiacreinstancePackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Block Instance</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * </p>
 * <ul>
 *   <li>{@link com.irtsaintexupery.fiacre.instance.fiacreinstance.impl.BlockInstanceImpl#getBlockInstances <em>Block Instances</em>}</li>
 * </ul>
 *
 * @generated
 */
public abstract class BlockInstanceImpl extends MinimalEObjectImpl.Container implements BlockInstance {
	/**
	 * The cached value of the '{@link #getBlockInstances() <em>Block Instances</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBlockInstances()
	 * @generated
	 * @ordered
	 */
	protected EList<BlockInstance> blockInstances;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<BlockInstance> getBlockInstances() {
		if (blockInstances == null) {
			blockInstances = new EObjectContainmentEList<BlockInstance>(BlockInstance.class, this, FiacreinstancePackage.BLOCK_INSTANCE__BLOCK_INSTANCES);
		}
		return blockInstances;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case FiacreinstancePackage.BLOCK_INSTANCE__BLOCK_INSTANCES:
				return ((InternalEList<?>)getBlockInstances()).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 FiacreinstancePackage.BLOCK_INSTANCE__BLOCK_INSTANCES:
				return getBlockInstances();
		}
		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 FiacreinstancePackage.BLOCK_INSTANCE__BLOCK_INSTANCES:
				getBlockInstances().clear();
				getBlockInstances().addAll((Collection<? extends BlockInstance>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case FiacreinstancePackage.BLOCK_INSTANCE__BLOCK_INSTANCES:
				getBlockInstances().clear();
				return;
		}
		super.eUnset(featureID);
	}

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

} //BlockInstanceImpl
