| /* |
| * Copyright (c) 2011, 2018 CEA and others. |
| * 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 |
| * http://www.eclipse.org/legal/epl-v20.html |
| * |
| * Contributors: |
| * Kenn Hussey (CEA) - initial API and implementation |
| * Kenn Hussey (CEA) - 397324 |
| * Kenn Hussey - 535301 |
| * |
| */ |
| package org.eclipse.uml2.types.internal.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.eclipse.uml2.types.*; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model <b>Factory</b>. |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public class TypesFactoryImpl |
| extends EFactoryImpl |
| implements TypesFactory { |
| |
| /** |
| * Creates the default factory implementation. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static TypesFactory init() { |
| try { |
| TypesFactory theTypesFactory = (TypesFactory) EPackage.Registry.INSTANCE |
| .getEFactory(TypesPackage.eNS_URI); |
| if (theTypesFactory != null) { |
| return theTypesFactory; |
| } |
| } catch (Exception exception) { |
| EcorePlugin.INSTANCE.log(exception); |
| } |
| return new TypesFactoryImpl(); |
| } |
| |
| /** |
| * Creates an instance of the factory. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TypesFactoryImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EObject create(EClass eClass) { |
| switch (eClass.getClassifierID()) { |
| 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 TypesPackage.BOOLEAN : |
| return createBooleanFromString(eDataType, initialValue); |
| case TypesPackage.INTEGER : |
| return createIntegerFromString(eDataType, initialValue); |
| case TypesPackage.REAL : |
| return createRealFromString(eDataType, initialValue); |
| case TypesPackage.STRING : |
| return createStringFromString(eDataType, initialValue); |
| case TypesPackage.UNLIMITED_NATURAL : |
| return createUnlimitedNaturalFromString(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 TypesPackage.BOOLEAN : |
| return convertBooleanToString(eDataType, instanceValue); |
| case TypesPackage.INTEGER : |
| return convertIntegerToString(eDataType, instanceValue); |
| case TypesPackage.REAL : |
| return convertRealToString(eDataType, instanceValue); |
| case TypesPackage.STRING : |
| return convertStringToString(eDataType, instanceValue); |
| case TypesPackage.UNLIMITED_NATURAL : |
| return convertUnlimitedNaturalToString(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 NOT |
| */ |
| public Boolean createBooleanFromString(EDataType eDataType, |
| String initialValue) { |
| return initialValue == null |
| ? null |
| : Boolean.valueOf(initialValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String convertBooleanToString(EDataType eDataType, |
| Object instanceValue) { |
| return instanceValue == null |
| ? null |
| : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public Integer createIntegerFromString(EDataType eDataType, |
| String initialValue) { |
| return initialValue == null |
| ? null |
| : Integer.valueOf(initialValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String convertIntegerToString(EDataType eDataType, |
| Object instanceValue) { |
| return instanceValue == null |
| ? null |
| : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public Double createRealFromString(EDataType eDataType, String initialValue) { |
| return initialValue == null |
| ? null |
| : Double.valueOf(initialValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String convertRealToString(EDataType eDataType, Object instanceValue) { |
| return instanceValue == null |
| ? null |
| : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String createStringFromString(EDataType eDataType, |
| String initialValue) { |
| return initialValue; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String convertStringToString(EDataType eDataType, |
| Object instanceValue) { |
| return (String) instanceValue; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public Integer createUnlimitedNaturalFromString(EDataType eDataType, |
| String initialValue) { |
| return initialValue == null |
| ? null |
| : ("*".equals(initialValue) //$NON-NLS-1$ |
| ? new Integer(-1) |
| : Integer.valueOf(initialValue)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated NOT |
| */ |
| public String convertUnlimitedNaturalToString(EDataType eDataType, |
| Object instanceValue) { |
| return instanceValue == null |
| ? null |
| : (((Integer) instanceValue).intValue() == -1 |
| ? "*" //$NON-NLS-1$ |
| : instanceValue.toString()); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public TypesPackage getTypesPackage() { |
| return (TypesPackage) getEPackage(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @deprecated |
| * @generated |
| */ |
| @Deprecated |
| public static TypesPackage getPackage() { |
| return TypesPackage.eINSTANCE; |
| } |
| |
| } //TypesFactoryImpl |