Skip to content
Snippets Groups Projects
Select Git revision
  • develop default protected
  • simmc-based
  • drill-experiment
  • tg-felipe
  • issue/97
  • issue/63
  • icde-2019-experiments
  • issue/85
  • master protected
  • issue/20
  • refactor/engine
  • issue/6
  • feature/diagrams
  • wip-transformers
14 results

enumHandler.ts

Blame
  • 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 : "";
        }
    
    }