AllarmiConverterUtils.java

  1. /*
  2.  * GovWay - A customizable API Gateway
  3.  * https://govway.org
  4.  *
  5.  * Copyright (c) 2005-2025 Link.it srl (https://link.it).
  6.  *
  7.  * This program is free software: you can redistribute it and/or modify
  8.  * it under the terms of the GNU General Public License version 3, as published by
  9.  * the Free Software Foundation.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18.  *
  19.  */

  20. package org.openspcoop2.core.allarmi.utils;

  21. import org.openspcoop2.core.allarmi.constants.StatoAllarme;
  22. import org.openspcoop2.core.allarmi.constants.TipoPeriodo;

  23. /**    
  24.  * AllarmiConverterUtils
  25.  *
  26.  * @author Poli Andrea (poli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public class AllarmiConverterUtils {

  31.     public static int toIntegerValue(StatoAllarme stato) {
  32.         switch (stato) {
  33.         case OK:
  34.             return 0;
  35.         case WARNING:
  36.             return 1;
  37.         case ERROR:
  38.             return 2;
  39.         }
  40.         return -1;
  41.     }
  42.    
  43.     public static StatoAllarme toStatoAllarme(Integer stato) {
  44.         if(stato==null) {
  45.             return null;
  46.         }
  47.         switch (stato) {
  48.         case 0:
  49.             return StatoAllarme.OK;
  50.         case 1:
  51.             return StatoAllarme.WARNING;
  52.         case 2:
  53.             return StatoAllarme.ERROR;
  54.         }
  55.         return null;
  56.     }
  57.    
  58.    
  59.     public static String toValue(TipoPeriodo tipo) {
  60.         return tipo.getValue()+"";
  61.     }
  62.    
  63.     public static TipoPeriodo toTipoPeriodo(String v) {
  64.         return TipoPeriodo.toEnumConstant(v.charAt(0));
  65.     }
  66.    
  67. }