/*******************************************************************************
 * Copyright (c) 2018 IRT AESE (IRT Saint Exupéry).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0
 *
 * Contributors:
 *     Arnaud Dieumegard (IRT Saint Exupéry) - initial API and implementation
 *******************************************************************************/
/**
 */
package com.irtsaintexupery.pseim.pseim.impl;

import com.irtsaintexupery.pseim.pseim.*;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;

import org.eclipse.emf.ecore.impl.EFactoryImpl;

import org.eclipse.emf.ecore.plugin.EcorePlugin;
import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model <b>Factory</b>.
 * <!-- end-user-doc -->
 * @generated
 */
public class PseimFactoryImpl extends EFactoryImpl implements PseimFactory {
	/**
	 * Creates the default factory implementation.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public static PseimFactory init() {
		try {
			PseimFactory thePseimFactory = (PseimFactory) EPackage.Registry.INSTANCE.getEFactory(PseimPackage.eNS_URI);
			if (thePseimFactory != null) {
				return thePseimFactory;
			}
		} catch (Exception exception) {
			EcorePlugin.INSTANCE.log(exception);
		}
		return new PseimFactoryImpl();
	}

	/**
	 * Creates an instance of the factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PseimFactoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public EObject create(EClass eClass) {
		switch (eClass.getClassifierID()) {
		case PseimPackage.LIBRARY:
			return createLibrary();
		case PseimPackage.PATTERN:
			return createPattern();
		case PseimPackage.CARDINALITY_ELEMENT:
			return createCardinalityElement();
		case PseimPackage.PATTERN_COMPONENT:
			return createPatternComponent();
		case PseimPackage.PATTERN_PORT:
			return createPatternPort();
		case PseimPackage.PATTERN_LINK:
			return createPatternLink();
		default:
			throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object createFromString(EDataType eDataType, String initialValue) {
		switch (eDataType.getClassifierID()) {
		case PseimPackage.PATTERN_TYPE_HS:
			return createPatternTypeHSFromString(eDataType, initialValue);
		case PseimPackage.PATTERN_TYPE_FAILURE_MODE:
			return createPatternTypeFailureModeFromString(eDataType, initialValue);
		case PseimPackage.SAFETY_TACTIC:
			return createSafetyTacticFromString(eDataType, initialValue);
		case PseimPackage.LINK_TYPE:
			return createLinkTypeFromString(eDataType, initialValue);
		case PseimPackage.PATTERN_PORT_DIRECTION:
			return createPatternPortDirectionFromString(eDataType, initialValue);
		default:
			throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String convertToString(EDataType eDataType, Object instanceValue) {
		switch (eDataType.getClassifierID()) {
		case PseimPackage.PATTERN_TYPE_HS:
			return convertPatternTypeHSToString(eDataType, instanceValue);
		case PseimPackage.PATTERN_TYPE_FAILURE_MODE:
			return convertPatternTypeFailureModeToString(eDataType, instanceValue);
		case PseimPackage.SAFETY_TACTIC:
			return convertSafetyTacticToString(eDataType, instanceValue);
		case PseimPackage.LINK_TYPE:
			return convertLinkTypeToString(eDataType, instanceValue);
		case PseimPackage.PATTERN_PORT_DIRECTION:
			return convertPatternPortDirectionToString(eDataType, instanceValue);
		default:
			throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
		}
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public Library createLibrary() {
		LibraryImpl library = new LibraryImpl();
		library.uid = EcoreUtil.generateUUID();
		return library;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Pattern createPattern() {
		PatternImpl pattern = new PatternImpl();
		return pattern;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public CardinalityElement createCardinalityElement() {
		CardinalityElementImpl cardinalityElement = new CardinalityElementImpl();
		cardinalityElement.uid = EcoreUtil.generateUUID();
		return cardinalityElement;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public PatternComponent createPatternComponent() {
		PatternComponentImpl patternComponent = new PatternComponentImpl();
		patternComponent.uid = EcoreUtil.generateUUID();
		return patternComponent;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public PatternPort createPatternPort() {
		PatternPortImpl patternPort = new PatternPortImpl();
		patternPort.uid = EcoreUtil.generateUUID();
		return patternPort;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public PatternLink createPatternLink() {
		PatternLinkImpl patternLink = new PatternLinkImpl();
		patternLink.uid = EcoreUtil.generateUUID();
		return patternLink;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PatternTypeHS createPatternTypeHSFromString(EDataType eDataType, String initialValue) {
		PatternTypeHS result = PatternTypeHS.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException(
					"The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertPatternTypeHSToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PatternTypeFailureMode createPatternTypeFailureModeFromString(EDataType eDataType, String initialValue) {
		PatternTypeFailureMode result = PatternTypeFailureMode.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException(
					"The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertPatternTypeFailureModeToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SafetyTactic createSafetyTacticFromString(EDataType eDataType, String initialValue) {
		SafetyTactic result = SafetyTactic.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException(
					"The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertSafetyTacticToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public LinkType createLinkTypeFromString(EDataType eDataType, String initialValue) {
		LinkType result = LinkType.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException(
					"The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertLinkTypeToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PatternPortDirection createPatternPortDirectionFromString(EDataType eDataType, String initialValue) {
		PatternPortDirection result = PatternPortDirection.get(initialValue);
		if (result == null)
			throw new IllegalArgumentException(
					"The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'");
		return result;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String convertPatternPortDirectionToString(EDataType eDataType, Object instanceValue) {
		return instanceValue == null ? null : instanceValue.toString();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public PseimPackage getPseimPackage() {
		return (PseimPackage) getEPackage();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @deprecated
	 * @generated
	 */
	@Deprecated
	public static PseimPackage getPackage() {
		return PseimPackage.eINSTANCE;
	}

} //PseimFactoryImpl
