TipoIntervalloStatistico.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 java.util.List;

  23. import org.openspcoop2.generic_project.beans.IEnumeration;
  24. import org.openspcoop2.generic_project.exception.NotFoundException;

  25. /**    
  26.  * Enumeration dell'elemento tipo-intervallo-statistico xsd (tipo:string)
  27.  *
  28.  * @author Poli Andrea (poli@link.it)
  29.  * @author Tommaso Burlon (tommaso.burlon@link.it)
  30.  * @author $Author$
  31.  * @version $Rev$, $Date$
  32.  */
  33. @javax.xml.bind.annotation.XmlType(name = "tipo-intervallo-statistico")
  34. @javax.xml.bind.annotation.XmlEnum(String.class)
  35. public enum TipoIntervalloStatistico implements IEnumeration , Serializable , Cloneable {

  36.     @javax.xml.bind.annotation.XmlEnumValue("StatisticheOrarie")
  37.     STATISTICHE_ORARIE ("StatisticheOrarie"),
  38.     @javax.xml.bind.annotation.XmlEnumValue("StatisticheGiornaliere")
  39.     STATISTICHE_GIORNALIERE ("StatisticheGiornaliere"),
  40.     @javax.xml.bind.annotation.XmlEnumValue("StatisticheSettimanali")
  41.     STATISTICHE_SETTIMANALI ("StatisticheSettimanali"),
  42.     @javax.xml.bind.annotation.XmlEnumValue("StatisticheMensili")
  43.     STATISTICHE_MENSILI ("StatisticheMensili"),
  44.     @javax.xml.bind.annotation.XmlEnumValue("PdndGenerazioneTracciamento")
  45.     PDND_GENERAZIONE_TRACCIAMENTO ("PdndGenerazioneTracciamento"),
  46.     @javax.xml.bind.annotation.XmlEnumValue("PdndPubblicazioneTracciamento")
  47.     PDND_PUBBLICAZIONE_TRACCIAMENTO ("PdndPubblicazioneTracciamento");
  48.    
  49.    
  50.     /** Value */
  51.     private String value;
  52.     @Override
  53.     public String getValue()
  54.     {
  55.         return this.value;
  56.     }


  57.     /** Official Constructor */
  58.     TipoIntervalloStatistico(String value)
  59.     {
  60.         this.value = value;
  61.     }


  62.    
  63.     @Override
  64.     public String toString(){
  65.         return this.value;
  66.     }
  67.     public boolean equals(String object){
  68.         if(object==null)
  69.             return false;
  70.         return object.equals(this.getValue());  
  71.     }
  72.    
  73.        
  74.    
  75.     /** compatibility with the generated bean (reflection) */
  76.     public boolean equals(Object object,List<String> fieldsNotCheck){
  77.         if( !(object instanceof TipoIntervalloStatistico) ){
  78.             java.lang.StringBuilder sb = new java.lang.StringBuilder();
  79.             if(fieldsNotCheck!=null && !fieldsNotCheck.isEmpty()){
  80.                 sb.append(" (fieldsNotCheck: ").append(fieldsNotCheck).append(")");
  81.             }
  82.             throw new org.openspcoop2.utils.UtilsRuntimeException("Wrong type"+sb.toString()+": "+object.getClass().getName());
  83.         }
  84.         return this.equals(object);
  85.     }
  86.     private String toStringEngine(Object object,boolean reportHTML,List<String> fieldsNotIncluded, StringBuilder bf){
  87.         java.lang.StringBuilder sb = new java.lang.StringBuilder();
  88.         if(reportHTML){
  89.             sb.append(" (reportHTML)");
  90.         }
  91.         if(fieldsNotIncluded!=null && !fieldsNotIncluded.isEmpty()){
  92.             sb.append(" (fieldsNotIncluded: ").append(fieldsNotIncluded).append(")");
  93.         }
  94.         if(object!=null){
  95.             sb.append(" (object: ").append(object.getClass().getName()).append(")");
  96.         }
  97.         if(sb.length()>0) {
  98.             bf.append(sb.toString());
  99.         }
  100.         return sb.length()>0 ? this.toString()+sb.toString() : this.toString();
  101.     }
  102.     public String toString(boolean reportHTML){
  103.         return toStringEngine(null, reportHTML, null, null);
  104.     }
  105.     public String toString(boolean reportHTML,List<String> fieldsNotIncluded){
  106.         return toStringEngine(null, reportHTML, fieldsNotIncluded, null);
  107.     }
  108.     public String diff(Object object,StringBuilder bf,boolean reportHTML){
  109.         return toStringEngine(object, reportHTML, null, bf);
  110.     }
  111.     public String diff(Object object,StringBuilder bf,boolean reportHTML,List<String> fieldsNotIncluded){
  112.         return toStringEngine(object, reportHTML, fieldsNotIncluded, bf);
  113.     }
  114.    
  115.    
  116.     /** Utilities */
  117.    
  118.     public static String[] toArray(){
  119.         String[] res = new String[values().length];
  120.         int i=0;
  121.         for (TipoIntervalloStatistico tmp : values()) {
  122.             res[i]=tmp.getValue();
  123.             i++;
  124.         }
  125.         return res;
  126.     }  
  127.     public static String[] toStringArray(){
  128.         String[] res = new String[values().length];
  129.         int i=0;
  130.         for (TipoIntervalloStatistico tmp : values()) {
  131.             res[i]=tmp.toString();
  132.             i++;
  133.         }
  134.         return res;
  135.     }
  136.     public static String[] toEnumNameArray(){
  137.         String[] res = new String[values().length];
  138.         int i=0;
  139.         for (TipoIntervalloStatistico tmp : values()) {
  140.             res[i]=tmp.name();
  141.             i++;
  142.         }
  143.         return res;
  144.     }
  145.    
  146.     public static boolean contains(String value){
  147.         return toEnumConstant(value)!=null;
  148.     }
  149.    
  150.     public static TipoIntervalloStatistico toEnumConstant(String value){
  151.         try{
  152.             return toEnumConstant(value,false);
  153.         }catch(NotFoundException notFound){
  154.             return null;
  155.         }
  156.     }
  157.     public static TipoIntervalloStatistico toEnumConstant(String value, boolean throwNotFoundException) throws NotFoundException{
  158.         TipoIntervalloStatistico res = null;
  159.         for (TipoIntervalloStatistico tmp : values()) {
  160.             if(tmp.getValue().equals(value)){
  161.                 res = tmp;
  162.                 break;
  163.             }
  164.         }
  165.         if(res==null && throwNotFoundException){
  166.             throw new NotFoundException("Enum with value ["+value+"] not found");
  167.         }
  168.         return res;
  169.     }
  170.    
  171.     public static IEnumeration toEnumConstantFromString(String value){
  172.         try{
  173.             return toEnumConstantFromString(value,false);
  174.         }catch(NotFoundException notFound){
  175.             return null;
  176.         }
  177.     }
  178.     public static IEnumeration toEnumConstantFromString(String value, boolean throwNotFoundException) throws NotFoundException{
  179.         TipoIntervalloStatistico res = null;
  180.         for (TipoIntervalloStatistico tmp : values()) {
  181.             if(tmp.toString().equals(value)){
  182.                 res = tmp;
  183.                 break;
  184.             }
  185.         }
  186.         if(res==null && throwNotFoundException){
  187.             throw new NotFoundException("Enum with value ["+value+"] not found");
  188.         }
  189.         return res;
  190.     }
  191. }