TipoEvento.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.eventi.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 TipoEvento xsd (tipo:string)
  27.  *
  28.  * @author Poli Andrea (poli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. @javax.xml.bind.annotation.XmlType(name = "TipoEvento")
  33. @javax.xml.bind.annotation.XmlEnum(String.class)
  34. public enum TipoEvento implements IEnumeration , Serializable , Cloneable {

  35.     @javax.xml.bind.annotation.XmlEnumValue("StatoGateway")
  36.     STATO_GATEWAY ("StatoGateway"),
  37.     @javax.xml.bind.annotation.XmlEnumValue("ControlloTraffico_NumeroMassimoRichiesteSimultanee")
  38.     CONTROLLO_TRAFFICO_NUMERO_MASSIMO_RICHIESTE_SIMULTANEE ("ControlloTraffico_NumeroMassimoRichiesteSimultanee"),
  39.     @javax.xml.bind.annotation.XmlEnumValue("ControlloTraffico_SogliaCongestione")
  40.     CONTROLLO_TRAFFICO_SOGLIA_CONGESTIONE ("ControlloTraffico_SogliaCongestione"),
  41.     @javax.xml.bind.annotation.XmlEnumValue("RateLimiting_PolicyGlobale")
  42.     RATE_LIMITING_POLICY_GLOBALE ("RateLimiting_PolicyGlobale"),
  43.     @javax.xml.bind.annotation.XmlEnumValue("RateLimiting_PolicyAPI")
  44.     RATE_LIMITING_POLICY_API ("RateLimiting_PolicyAPI"),
  45.     @javax.xml.bind.annotation.XmlEnumValue("ControlloTraffico_ConnectionTimeout")
  46.     CONTROLLO_TRAFFICO_CONNECTION_TIMEOUT ("ControlloTraffico_ConnectionTimeout"),
  47.     @javax.xml.bind.annotation.XmlEnumValue("ControlloTraffico_RequestReadTimeout")
  48.     CONTROLLO_TRAFFICO_REQUEST_READ_TIMEOUT ("ControlloTraffico_RequestReadTimeout"),
  49.     @javax.xml.bind.annotation.XmlEnumValue("ControlloTraffico_ReadTimeout")
  50.     CONTROLLO_TRAFFICO_READ_TIMEOUT ("ControlloTraffico_ReadTimeout");
  51.    
  52.    
  53.     /** Value */
  54.     private String value;
  55.     @Override
  56.     public String getValue()
  57.     {
  58.         return this.value;
  59.     }


  60.     /** Official Constructor */
  61.     TipoEvento(String value)
  62.     {
  63.         this.value = value;
  64.     }


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