/**
 */
package org.xtext.example.mydsl2.myDsl2.impl;

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.xtext.example.mydsl2.myDsl2.*;

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

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

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public EObject create(EClass eClass)
  {
    switch (eClass.getClassifierID())
    {
      case MyDsl2Package.USER_MODEL: return createUserModel();
      case MyDsl2Package.SITE_PERMISSION: return createSitePermission();
      case MyDsl2Package.PRINCIPLE: return createPrinciple();
      case MyDsl2Package.GROUP: return createGroup();
      case MyDsl2Package.USER: return createUser();
      case MyDsl2Package.ROLE_ASSIGNMENT: return createRoleAssignment();
      case MyDsl2Package.ROLE_DEFINITION: return createRoleDefinition();
      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 MyDsl2Package.BASE_PERMISSION:
        return createBasePermissionFromString(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 MyDsl2Package.BASE_PERMISSION:
        return convertBasePermissionToString(eDataType, instanceValue);
      default:
        throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
    }
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public UserModel createUserModel()
  {
    UserModelImpl userModel = new UserModelImpl();
    return userModel;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public SitePermission createSitePermission()
  {
    SitePermissionImpl sitePermission = new SitePermissionImpl();
    return sitePermission;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Principle createPrinciple()
  {
    PrincipleImpl principle = new PrincipleImpl();
    return principle;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Group createGroup()
  {
    GroupImpl group = new GroupImpl();
    return group;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public User createUser()
  {
    UserImpl user = new UserImpl();
    return user;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RoleAssignment createRoleAssignment()
  {
    RoleAssignmentImpl roleAssignment = new RoleAssignmentImpl();
    return roleAssignment;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public RoleDefinition createRoleDefinition()
  {
    RoleDefinitionImpl roleDefinition = new RoleDefinitionImpl();
    return roleDefinition;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public BasePermission createBasePermissionFromString(EDataType eDataType, String initialValue)
  {
    BasePermission result = BasePermission.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 convertBasePermissionToString(EDataType eDataType, Object instanceValue)
  {
    return instanceValue == null ? null : instanceValue.toString();
  }

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

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

} //MyDsl2FactoryImpl
