Select Git revision
enumHandler.ts
-
Rafael Dias authored
Signed-off-by:
Rafael <rpd17@inf.ufpr.br>
Rafael Dias authoredSigned-off-by:
Rafael <rpd17@inf.ufpr.br>
enumHandler.ts 1.65 KiB
import { DataType } from "../common/types";
/*
* Copyright (C) 2018 Centro de Computacao Cientifica e Software Livre
* Departamento de Informatica - Universidade Federal do Parana
*
* This file is part of blendb.
*
* blendb is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* blendb is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with blendb. If not, see <http://www.gnu.org/licenses/>.
*/
import { EnumType } from "../core/enumType";
/**
* Enum's handler. Manage changes between
* string , datatype and enumtype.
*/
export class EnumHandler {
/**
* Checks if it's a valid datatype, otherwise will be an enumtype
* @param dt datatype to compare, used as return if comparation succeed
* @param en enumtype as return if comparation fails
*/
public static selectDataType(dt: DataType , en: string): string{
return (dt !== DataType.NONE) ? EnumType.stringfyDataType(dt) : en;
}
/**
* Checks if it's a valid datatype, otherwise return an empity string
* @param data datatype to compare, used as return if comparation succeed
*/
public static selectEnumType(dt: string): string{
return (EnumType.parseDataType(dt) === DataType.NONE) ? dt : "";
}
}