/*******************************************************************************
 * 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.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import com.irtsaintexupery.fiacre.instance.fiacreinstance.FiacreinstancePackage;
import com.irtsaintexupery.fiacre.instance.fiacreinstance.InstanceStatementBlock;
import com.irtsaintexupery.fiacre.instance.fiacreinstance.StatementBlock;

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

	/**
	 * 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;

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

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<InstanceStatementBlock> getInstanceStatementBlocks() {
		if (instanceStatementBlocks == null) {
			instanceStatementBlocks = new EObjectResolvingEList<InstanceStatementBlock>(InstanceStatementBlock.class, this, FiacreinstancePackage.STATEMENT_BLOCK__INSTANCE_STATEMENT_BLOCKS);
		}
		return instanceStatementBlocks;
	}

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

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case FiacreinstancePackage.STATEMENT_BLOCK__INSTANCE_STATEMENT_BLOCKS:
				return getInstanceStatementBlocks();
			case FiacreinstancePackage.STATEMENT_BLOCK__NAME:
				return getName();
		}
		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.STATEMENT_BLOCK__INSTANCE_STATEMENT_BLOCKS:
				getInstanceStatementBlocks().clear();
				getInstanceStatementBlocks().addAll((Collection<? extends InstanceStatementBlock>)newValue);
				return;
			case FiacreinstancePackage.STATEMENT_BLOCK__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

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

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

} //StatementBlockImpl
