SondaStatus.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.monitor.engine.constants;

  21. import java.io.Serializable;

  22. import org.openspcoop2.generic_project.beans.IEnumeration;

  23. /**
  24.  * SondaStatus
  25.  *
  26.  * @author Pintori Giuliano (pintori@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  *
  30.  */
  31. public enum SondaStatus implements IEnumeration , Serializable , Cloneable{

  32.     OK ("ok"), WARNING ("warning"), ERROR ("error"), UNDEFINED("undefined");

  33.     /** Value */
  34.     private String value;
  35.     @Override
  36.     public String getValue()
  37.     {
  38.         return this.value;
  39.     }


  40.     /** Official Constructor */
  41.     SondaStatus(String value)
  42.     {
  43.         this.value = value;
  44.     }

  45.     @Override
  46.     public String toString(){
  47.         return this.value;
  48.     }
  49.     public boolean equals(String object){
  50.         if(object==null)
  51.             return false;
  52.         return object.equals(this.getValue());  
  53.     }

  54.     /** Utilities */

  55.     public static String[] toArray(){
  56.         String[] res = new String[SondaStatus.values().length];
  57.         int i=0;
  58.         for (SondaStatus tmp : SondaStatus.values()) {
  59.             res[i]=tmp.getValue();
  60.             i++;
  61.         }
  62.         return res;
  63.     }  
  64.     public static String[] toStringArray(){
  65.         String[] res = new String[SondaStatus.values().length];
  66.         int i=0;
  67.         for (SondaStatus tmp : SondaStatus.values()) {
  68.             res[i]=tmp.toString();
  69.             i++;
  70.         }
  71.         return res;
  72.     }
  73.     public static String[] toEnumNameArray(){
  74.         String[] res = new String[SondaStatus.values().length];
  75.         int i=0;
  76.         for (SondaStatus tmp : SondaStatus.values()) {
  77.             res[i]=tmp.name();
  78.             i++;
  79.         }
  80.         return res;
  81.     }

  82.     public static boolean contains(String value){
  83.         return SondaStatus.toEnumConstant(value)!=null;
  84.     }

  85.     public static SondaStatus toEnumConstant(String value){
  86.         SondaStatus res = null;
  87.         if(SondaStatus.OK.getValue().equals(value)){
  88.             res = SondaStatus.OK;
  89.         }else if(SondaStatus.WARNING.getValue().equals(value)){
  90.             res = SondaStatus.WARNING;
  91.         }else if(SondaStatus.ERROR.getValue().equals(value)){
  92.             res = SondaStatus.ERROR;
  93.         } else if(SondaStatus.UNDEFINED.getValue().equals(value)){
  94.             res = SondaStatus.UNDEFINED;
  95.         }


  96.         return res;
  97.     }

  98.     public static IEnumeration toEnumConstantFromString(String value){
  99.         SondaStatus res = null;
  100.         if(SondaStatus.OK.toString().equals(value)){
  101.             res = SondaStatus.OK;
  102.         }else if(SondaStatus.WARNING.toString().equals(value)){
  103.             res = SondaStatus.WARNING;
  104.         }else if(SondaStatus.ERROR.toString().equals(value)){
  105.             res = SondaStatus.ERROR;
  106.         } else if(SondaStatus.UNDEFINED.toString().equals(value)){
  107.             res = SondaStatus.UNDEFINED;
  108.         }
  109.         return res;
  110.     }

  111. }