blob: 7fc2aa45875a145e9f5f8515f9eb8d4e28149703 [file] [log] [blame]
/*********************************************************************
* Copyright (c) 2011, 2019 SAP SE
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* Contributors:
* SAP SE - initial API, implementation and documentation
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipse.graphiti.examples.mm.chess.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.graphiti.examples.mm.chess.Board;
import org.eclipse.graphiti.examples.mm.chess.ChessFactory;
import org.eclipse.graphiti.examples.mm.chess.ChessPackage;
import org.eclipse.graphiti.examples.mm.chess.Colors;
import org.eclipse.graphiti.examples.mm.chess.Files;
import org.eclipse.graphiti.examples.mm.chess.Piece;
import org.eclipse.graphiti.examples.mm.chess.Ranks;
import org.eclipse.graphiti.examples.mm.chess.Square;
import org.eclipse.graphiti.examples.mm.chess.Types;
/**
* <!-- begin-user-doc --> An implementation of the model <b>Factory</b>. <!--
* end-user-doc -->
*
* @generated
*/
public class ChessFactoryImpl extends EFactoryImpl implements ChessFactory {
/**
* Creates the default factory implementation. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated
*/
public static ChessFactory init() {
try {
ChessFactory theChessFactory = (ChessFactory) EPackage.Registry.INSTANCE
.getEFactory("http://eclipse.org/graphiti/examples/chess");
if (theChessFactory != null) {
return theChessFactory;
}
} catch (Exception exception) {
EcorePlugin.INSTANCE.log(exception);
}
return new ChessFactoryImpl();
}
/**
* Creates an instance of the factory. <!-- begin-user-doc --> <!--
* end-user-doc -->
*
* @generated
*/
public ChessFactoryImpl() {
super();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public EObject create(EClass eClass) {
switch (eClass.getClassifierID()) {
case ChessPackage.BOARD:
return createBoard();
case ChessPackage.SQUARE:
return createSquare();
case ChessPackage.PIECE:
return createPiece();
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 ChessPackage.RANKS:
return createRanksFromString(eDataType, initialValue);
case ChessPackage.FILES:
return createFilesFromString(eDataType, initialValue);
case ChessPackage.COLORS:
return createColorsFromString(eDataType, initialValue);
case ChessPackage.TYPES:
return createTypesFromString(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 ChessPackage.RANKS:
return convertRanksToString(eDataType, instanceValue);
case ChessPackage.FILES:
return convertFilesToString(eDataType, instanceValue);
case ChessPackage.COLORS:
return convertColorsToString(eDataType, instanceValue);
case ChessPackage.TYPES:
return convertTypesToString(eDataType, instanceValue);
default:
throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier");
}
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Board createBoard() {
BoardImpl board = new BoardImpl();
return board;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Square createSquare() {
SquareImpl square = new SquareImpl();
return square;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Piece createPiece() {
PieceImpl piece = new PieceImpl();
return piece;
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Ranks createRanksFromString(EDataType eDataType, String initialValue) {
Ranks result = Ranks.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 convertRanksToString(EDataType eDataType, Object instanceValue) {
return instanceValue == null ? null : instanceValue.toString();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Files createFilesFromString(EDataType eDataType, String initialValue) {
Files result = Files.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 convertFilesToString(EDataType eDataType, Object instanceValue) {
return instanceValue == null ? null : instanceValue.toString();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Colors createColorsFromString(EDataType eDataType, String initialValue) {
Colors result = Colors.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 convertColorsToString(EDataType eDataType, Object instanceValue) {
return instanceValue == null ? null : instanceValue.toString();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public Types createTypesFromString(EDataType eDataType, String initialValue) {
Types result = Types.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 convertTypesToString(EDataType eDataType, Object instanceValue) {
return instanceValue == null ? null : instanceValue.toString();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
public ChessPackage getChessPackage() {
return (ChessPackage) getEPackage();
}
/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @deprecated
* @generated
*/
@Deprecated
public static ChessPackage getPackage() {
return ChessPackage.eINSTANCE;
}
} // ChessFactoryImpl