| /** |
| * Copyright (c) 2020 Eclipse contributors and others. |
| * |
| * 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 |
| */ |
| package org.eclipse.justj.codegen.model.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.justj.codegen.model.JVM; |
| import org.eclipse.justj.codegen.model.Model; |
| import org.eclipse.justj.codegen.model.ModelFactory; |
| import org.eclipse.justj.codegen.model.ModelPackage; |
| import org.eclipse.justj.codegen.model.Phase; |
| import org.eclipse.justj.codegen.model.Touchpoint; |
| import org.eclipse.justj.codegen.model.Variant; |
| |
| |
| /** |
| * <!-- begin-user-doc --> |
| * An implementation of the model <b>Factory</b>. |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public class ModelFactoryImpl extends EFactoryImpl implements ModelFactory |
| { |
| /** |
| * Creates the default factory implementation. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public static ModelFactory init() |
| { |
| try |
| { |
| ModelFactory theModelFactory = (ModelFactory)EPackage.Registry.INSTANCE.getEFactory(ModelPackage.eNS_URI); |
| if (theModelFactory != null) |
| { |
| return theModelFactory; |
| } |
| } |
| catch (Exception exception) |
| { |
| EcorePlugin.INSTANCE.log(exception); |
| } |
| return new ModelFactoryImpl(); |
| } |
| |
| /** |
| * Creates an instance of the factory. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public ModelFactoryImpl() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public EObject create(EClass eClass) |
| { |
| switch (eClass.getClassifierID()) |
| { |
| case ModelPackage.MODEL: |
| return createModel(); |
| case ModelPackage.JVM: |
| return createJVM(); |
| case ModelPackage.VARIANT: |
| return createVariant(); |
| case ModelPackage.TOUCHPOINT: |
| return createTouchpoint(); |
| 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 ModelPackage.PHASE: |
| return createPhaseFromString(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 ModelPackage.PHASE: |
| return convertPhaseToString(eDataType, instanceValue); |
| default: |
| throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Model createModel() |
| { |
| ModelImpl model = new ModelImpl(); |
| return model; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public JVM createJVM() |
| { |
| JVMImpl jvm = new JVMImpl(); |
| return jvm; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Variant createVariant() |
| { |
| VariantImpl variant = new VariantImpl(); |
| return variant; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Touchpoint createTouchpoint() |
| { |
| TouchpointImpl touchpoint = new TouchpointImpl(); |
| return touchpoint; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| public Phase createPhaseFromString(EDataType eDataType, String initialValue) |
| { |
| Phase result = Phase.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 convertPhaseToString(EDataType eDataType, Object instanceValue) |
| { |
| return instanceValue == null ? null : instanceValue.toString(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public ModelPackage getModelPackage() |
| { |
| return (ModelPackage)getEPackage(); |
| } |
| |
| } //ModelFactoryImpl |