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

  31.     BAR_CHART ("bar_chart"), PIE_CHART ("pie_chart"), TABELLA ("tabella"),  LINE_CHART ("line_chart"),
  32.         ANDAMENTO_TEMPORALE ("andamentoTemporale");

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

  40.     /** Official Constructor */
  41.     TipoReport(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[values().length];
  57.         int i=0;
  58.         for (TipoReport tmp : values()) {
  59.             res[i]=tmp.getValue();
  60.             i++;
  61.         }
  62.         return res;
  63.     }  
  64.     public static String[] toStringArray(){
  65.         String[] res = new String[values().length];
  66.         int i=0;
  67.         for (TipoReport tmp : values()) {
  68.             res[i]=tmp.toString();
  69.             i++;
  70.         }
  71.         return res;
  72.     }
  73.     public static String[] toEnumNameArray(){
  74.         String[] res = new String[values().length];
  75.         int i=0;
  76.         for (TipoReport tmp : values()) {
  77.             res[i]=tmp.name();
  78.             i++;
  79.         }
  80.         return res;
  81.     }

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

  85.     public static TipoReport toEnumConstant(String value){
  86.         TipoReport res = null;
  87.         if(TipoReport.BAR_CHART.getValue().equals(value)){
  88.             res = TipoReport.BAR_CHART;
  89.         }else if(TipoReport.PIE_CHART.getValue().equals(value)){
  90.             res = TipoReport.PIE_CHART;
  91.         }else if(TipoReport.LINE_CHART.getValue().equals(value)){
  92.             res = TipoReport.LINE_CHART;
  93.         }else if(TipoReport.TABELLA.getValue().equals(value)){
  94.             res = TipoReport.TABELLA;
  95.         }else if(TipoReport.ANDAMENTO_TEMPORALE.getValue().equals(value)){
  96.             res = TipoReport.ANDAMENTO_TEMPORALE;
  97.         }  


  98.         return res;
  99.     }

  100.     public static IEnumeration toEnumConstantFromString(String value){
  101.         TipoReport res = null;
  102.         if(TipoReport.BAR_CHART.toString().equals(value)){
  103.             res = TipoReport.BAR_CHART;
  104.         }else if(TipoReport.PIE_CHART.toString().equals(value)){
  105.             res = TipoReport.PIE_CHART;
  106.         }else if(TipoReport.LINE_CHART.toString().equals(value)){
  107.             res = TipoReport.LINE_CHART;
  108.         }else if(TipoReport.TABELLA.toString().equals(value)){
  109.             res = TipoReport.TABELLA;
  110.         }else if(TipoReport.ANDAMENTO_TEMPORALE.toString().equals(value)){
  111.             res = TipoReport.ANDAMENTO_TEMPORALE;
  112.         }  
  113.         return res;
  114.     }

  115. }