Severity.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.utils.logger.constants;

  21. import java.io.Serializable;

  22. /**
  23.  * Severity
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum Severity implements Serializable {

  30.     DEBUG_HIGH, DEBUG_MEDIUM, DEBUG_LOW, INFO, WARN, ERROR, FATAL;  
  31.    
  32.     public int intValue(){
  33.         switch (this) {
  34.         case FATAL:
  35.             return 0;
  36.         case ERROR:
  37.             return 1;
  38.         case WARN:
  39.             return 2;
  40.         case INFO:
  41.             return 3;
  42.         case DEBUG_LOW:
  43.             return 4;
  44.         case DEBUG_MEDIUM:
  45.             return 5;
  46.         case DEBUG_HIGH:
  47.             return 6;
  48.         }
  49.         return -1;
  50.     }
  51.    
  52.     public static Severity toSeverity(int value){
  53.         if(value == 0){
  54.             return FATAL;
  55.         }
  56.         else if(value == 1){
  57.             return ERROR;
  58.         }
  59.         else if(value == 2){
  60.             return WARN;
  61.         }
  62.         else if(value == 3){
  63.             return INFO;
  64.         }
  65.         else if(value == 4){
  66.             return DEBUG_LOW;
  67.         }
  68.         else if(value == 5){
  69.             return DEBUG_MEDIUM;
  70.         }
  71.         else if(value == 6){
  72.             return DEBUG_HIGH;
  73.         }
  74.         return null;
  75.     }
  76.    
  77. }