TipoStatistica.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.  * TipoStatistica
  25.  *
  26.  * @author Poli Andrea (poli@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */
  30. public enum TipoStatistica  implements IEnumeration , Serializable , Cloneable{

  31.     ANDAMENTO_TEMPORALE ("andamentoTemporale"),
  32.     DISTRIBUZIONE_ERRORI ("distribuzioneErrori"),
  33.     DISTRIBUZIONE_SOGGETTO ("distribuzioneSoggetto"),
  34.     DISTRIBUZIONE_SERVIZIO ("distribuzioneServizio"),
  35.     DISTRIBUZIONE_AZIONE ("distribuzioneAzione"),
  36.     DISTRIBUZIONE_SERVIZIO_APPLICATIVO ("distribuzioneSA"),
  37.     STATISTICA_PERSONALIZZATA ("statisticaPersonalizzata");

  38.     /** Value */
  39.     private String value;
  40.     @Override
  41.     public String getValue()
  42.     {
  43.         return this.value;
  44.     }


  45.     /** Official Constructor */
  46.     TipoStatistica(String value)
  47.     {
  48.         this.value = value;
  49.     }

  50.     @Override
  51.     public String toString(){
  52.         return this.value;
  53.     }
  54.     public boolean equals(String object){
  55.         if(object==null)
  56.             return false;
  57.         return object.equals(this.getValue());  
  58.     }

  59.     /** Utilities */

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

  87.     public static boolean contains(String value){
  88.         return toEnumConstant(value)!=null;
  89.     }

  90.     public static TipoStatistica toEnumConstant(String value){
  91.         TipoStatistica res = null;
  92.         if(TipoStatistica.ANDAMENTO_TEMPORALE.getValue().equals(value)){
  93.             res = TipoStatistica.ANDAMENTO_TEMPORALE;
  94.         }else if(TipoStatistica.DISTRIBUZIONE_ERRORI.getValue().equals(value)){
  95.             res = TipoStatistica.DISTRIBUZIONE_ERRORI;
  96.         }else if(TipoStatistica.DISTRIBUZIONE_SERVIZIO.getValue().equals(value)){
  97.             res = TipoStatistica.DISTRIBUZIONE_SERVIZIO;
  98.         }else if(TipoStatistica.DISTRIBUZIONE_SOGGETTO.getValue().equals(value)){
  99.             res = TipoStatistica.DISTRIBUZIONE_SOGGETTO;
  100.         }else if(TipoStatistica.DISTRIBUZIONE_SERVIZIO_APPLICATIVO.getValue().equals(value)){
  101.             res = TipoStatistica.DISTRIBUZIONE_SERVIZIO_APPLICATIVO;
  102.         }else if(TipoStatistica.STATISTICA_PERSONALIZZATA.getValue().equals(value)){
  103.             res = TipoStatistica.STATISTICA_PERSONALIZZATA;
  104.         }else if(TipoStatistica.DISTRIBUZIONE_AZIONE.getValue().equals(value)){
  105.             res = TipoStatistica.DISTRIBUZIONE_AZIONE;
  106.         }

  107.         return res;
  108.     }

  109.     public static IEnumeration toEnumConstantFromString(String value){
  110.         TipoStatistica res = null;
  111.         if(TipoStatistica.ANDAMENTO_TEMPORALE.toString().equals(value)){
  112.             res = TipoStatistica.ANDAMENTO_TEMPORALE;
  113.         } else if(TipoStatistica.DISTRIBUZIONE_ERRORI.toString().equals(value)){
  114.             res = TipoStatistica.DISTRIBUZIONE_ERRORI;
  115.         } else if(TipoStatistica.DISTRIBUZIONE_SERVIZIO.toString().equals(value)){
  116.             res = TipoStatistica.DISTRIBUZIONE_SERVIZIO;
  117.         }else if(TipoStatistica.DISTRIBUZIONE_SOGGETTO.toString().equals(value)){
  118.             res = TipoStatistica.DISTRIBUZIONE_SOGGETTO;
  119.         }else if(TipoStatistica.DISTRIBUZIONE_SERVIZIO_APPLICATIVO.toString().equals(value)){
  120.             res = TipoStatistica.DISTRIBUZIONE_SERVIZIO_APPLICATIVO;
  121.         }else if(TipoStatistica.STATISTICA_PERSONALIZZATA.toString().equals(value)){
  122.             res = TipoStatistica.STATISTICA_PERSONALIZZATA;
  123.         } else if(TipoStatistica.DISTRIBUZIONE_AZIONE.toString().equals(value)){
  124.             res = TipoStatistica.DISTRIBUZIONE_AZIONE;
  125.         }  
  126.         return res;
  127.     }

  128. }