TipoBanda.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.statistiche.constants;

  21. import java.io.Serializable;

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

  23. /**    
  24.  * TipoBanda
  25.  *
  26.  * @author Poli Andrea (poli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public enum TipoBanda  implements IEnumeration , Serializable , Cloneable{

  31.     INTERNA ("Banda Interna"), ESTERNA ("Banda Esterna"), COMPLESSIVA ("Banda Complessiva");

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


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

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

  53.     /** Utilities */

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

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

  84.     public static TipoBanda toEnumConstant(String value){
  85.         TipoBanda res = null;
  86.         if(TipoBanda.INTERNA.getValue().equals(value)){
  87.             res = TipoBanda.INTERNA;
  88.         }else if(TipoBanda.ESTERNA.getValue().equals(value)){
  89.             res = TipoBanda.ESTERNA;
  90.         }else if(TipoBanda.COMPLESSIVA.getValue().equals(value)){
  91.             res = TipoBanda.COMPLESSIVA;
  92.         }  


  93.         return res;
  94.     }

  95.     public static IEnumeration toEnumConstantFromString(String value){
  96.         TipoBanda res = null;
  97.         if(TipoBanda.INTERNA.toString().equals(value)){
  98.             res = TipoBanda.INTERNA;
  99.         }else if(TipoBanda.ESTERNA.toString().equals(value)){
  100.             res = TipoBanda.ESTERNA;
  101.         }else if(TipoBanda.COMPLESSIVA.toString().equals(value)){
  102.             res = TipoBanda.COMPLESSIVA;
  103.         }  
  104.         return res;
  105.     }

  106. }