| /* |
| * Copyright (c) 2009-2012, 2015 Eike Stepper (Berlin, Germany) and others. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Eike Stepper - initial API and implementation |
| * |
| * Initial Publication: |
| * Eclipse Magazin - http://www.eclipse-magazin.de |
| */ |
| package org.gastro.business.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.gastro.business.BusinessDay; |
| import org.gastro.business.BusinessFactory; |
| import org.gastro.business.BusinessPackage; |
| import org.gastro.business.Order; |
| import org.gastro.business.OrderDetail; |
| import org.gastro.business.OrderState; |
| import org.gastro.business.Waiter; |
| |
| /** |
| * <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!-- end-user-doc --> |
| * @generated |
| */ |
| public class BusinessFactoryImpl extends EFactoryImpl implements BusinessFactory |
| { |
| /** |
| * Creates the default factory implementation. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public static BusinessFactory init() |
| { |
| try |
| { |
| BusinessFactory theBusinessFactory = (BusinessFactory)EPackage.Registry.INSTANCE |
| .getEFactory("http://www.gastro.org/business/1.0"); |
| if (theBusinessFactory != null) |
| { |
| return theBusinessFactory; |
| } |
| } |
| catch (Exception exception) |
| { |
| EcorePlugin.INSTANCE.log(exception); |
| } |
| return new BusinessFactoryImpl(); |
| } |
| |
| /** |
| * Creates an instance of the factory. |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public BusinessFactoryImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EObject create(EClass eClass) |
| { |
| switch (eClass.getClassifierID()) |
| { |
| case BusinessPackage.BUSINESS_DAY: |
| return createBusinessDay(); |
| case BusinessPackage.ORDER: |
| return createOrder(); |
| case BusinessPackage.ORDER_DETAIL: |
| return createOrderDetail(); |
| case BusinessPackage.WAITER: |
| return createWaiter(); |
| 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 BusinessPackage.ORDER_STATE: |
| return createOrderStateFromString(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 BusinessPackage.ORDER_STATE: |
| return convertOrderStateToString(eDataType, instanceValue); |
| default: |
| throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public BusinessDay createBusinessDay() |
| { |
| BusinessDayImpl businessDay = new BusinessDayImpl(); |
| return businessDay; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Order createOrder() |
| { |
| OrderImpl order = new OrderImpl(); |
| return order; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public OrderDetail createOrderDetail() |
| { |
| OrderDetailImpl orderDetail = new OrderDetailImpl(); |
| return orderDetail; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public Waiter createWaiter() |
| { |
| WaiterImpl waiter = new WaiterImpl(); |
| return waiter; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public OrderState createOrderStateFromString(EDataType eDataType, String initialValue) |
| { |
| OrderState result = OrderState.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 convertOrderStateToString(EDataType eDataType, Object instanceValue) |
| { |
| return instanceValue == null ? null : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @generated |
| */ |
| public BusinessPackage getBusinessPackage() |
| { |
| return (BusinessPackage)getEPackage(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * @deprecated |
| * @generated |
| */ |
| @Deprecated |
| public static BusinessPackage getPackage() |
| { |
| return BusinessPackage.eINSTANCE; |
| } |
| |
| } // BusinessFactoryImpl |