| /** |
| * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * EclipseSource Munich - initial API and implementation |
| */ |
| package org.eclipse.emf.ecp.makeithappen.model.task.impl; |
| |
| import javax.xml.datatype.XMLGregorianCalendar; |
| |
| 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.xml.type.XMLTypeFactory; |
| import org.eclipse.emf.ecore.xml.type.XMLTypePackage; |
| import org.eclipse.emf.ecp.makeithappen.model.task.Gender; |
| import org.eclipse.emf.ecp.makeithappen.model.task.Nationality; |
| import org.eclipse.emf.ecp.makeithappen.model.task.Task; |
| import org.eclipse.emf.ecp.makeithappen.model.task.TaskFactory; |
| import org.eclipse.emf.ecp.makeithappen.model.task.TaskPackage; |
| import org.eclipse.emf.ecp.makeithappen.model.task.User; |
| import org.eclipse.emf.ecp.makeithappen.model.task.UserGroup; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model <b>Factory</b>. |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public class TaskFactoryImpl extends EFactoryImpl implements TaskFactory |
| { |
| /** |
| * Creates the default factory implementation. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public static TaskFactory init() |
| { |
| try |
| { |
| final TaskFactory theTaskFactory = (TaskFactory) EPackage.Registry.INSTANCE |
| .getEFactory(TaskPackage.eNS_URI); |
| if (theTaskFactory != null) |
| { |
| return theTaskFactory; |
| } |
| } catch (final Exception exception) |
| { |
| EcorePlugin.INSTANCE.log(exception); |
| } |
| return new TaskFactoryImpl(); |
| } |
| |
| /** |
| * Creates an instance of the factory. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public TaskFactoryImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public EObject create(EClass eClass) |
| { |
| switch (eClass.getClassifierID()) |
| { |
| case TaskPackage.TASK: |
| return createTask(); |
| case TaskPackage.USER: |
| return createUser(); |
| case TaskPackage.USER_GROUP: |
| return createUserGroup(); |
| default: |
| throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object createFromString(EDataType eDataType, String initialValue) |
| { |
| switch (eDataType.getClassifierID()) |
| { |
| case TaskPackage.GENDER: |
| return createGenderFromString(eDataType, initialValue); |
| case TaskPackage.NATIONALITY: |
| return createNationalityFromString(eDataType, initialValue); |
| case TaskPackage.DATE_OF_BIRTH: |
| return createDateOfBirthFromString(eDataType, initialValue); |
| default: |
| throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public String convertToString(EDataType eDataType, Object instanceValue) |
| { |
| switch (eDataType.getClassifierID()) |
| { |
| case TaskPackage.GENDER: |
| return convertGenderToString(eDataType, instanceValue); |
| case TaskPackage.NATIONALITY: |
| return convertNationalityToString(eDataType, instanceValue); |
| case TaskPackage.DATE_OF_BIRTH: |
| return convertDateOfBirthToString(eDataType, instanceValue); |
| default: |
| throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); //$NON-NLS-1$ //$NON-NLS-2$ |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Task createTask() |
| { |
| final TaskImpl task = new TaskImpl(); |
| return task; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public User createUser() |
| { |
| final UserImpl user = new UserImpl(); |
| return user; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public UserGroup createUserGroup() |
| { |
| final UserGroupImpl userGroup = new UserGroupImpl(); |
| return userGroup; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public Gender createGenderFromString(EDataType eDataType, String initialValue) |
| { |
| final Gender result = Gender.get(initialValue); |
| if (result == null) |
| { |
| throw new IllegalArgumentException( |
| "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| } |
| return result; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public String convertGenderToString(EDataType eDataType, Object instanceValue) |
| { |
| return instanceValue == null ? null : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public Nationality createNationalityFromString(EDataType eDataType, String initialValue) |
| { |
| final Nationality result = Nationality.get(initialValue); |
| if (result == null) |
| { |
| throw new IllegalArgumentException( |
| "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
| } |
| return result; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public String convertNationalityToString(EDataType eDataType, Object instanceValue) |
| { |
| return instanceValue == null ? null : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public XMLGregorianCalendar createDateOfBirthFromString(EDataType eDataType, String initialValue) |
| { |
| return (XMLGregorianCalendar) XMLTypeFactory.eINSTANCE.createFromString(XMLTypePackage.Literals.DATE, |
| initialValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| public String convertDateOfBirthToString(EDataType eDataType, Object instanceValue) |
| { |
| return XMLTypeFactory.eINSTANCE.convertToString(XMLTypePackage.Literals.DATE, instanceValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public TaskPackage getTaskPackage() |
| { |
| return (TaskPackage) getEPackage(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * |
| * @deprecated |
| * @generated |
| */ |
| @Deprecated |
| public static TaskPackage getPackage() |
| { |
| return TaskPackage.eINSTANCE; |
| } |
| |
| } // TaskFactoryImpl |