TipoRilevanzaEccezione.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.tracciamento.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 TipoRilevanzaEccezione 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 = "TipoRilevanzaEccezione")
  33. @javax.xml.bind.annotation.XmlEnum(String.class)
  34. public enum TipoRilevanzaEccezione implements IEnumeration , Serializable , Cloneable {

  35.     @javax.xml.bind.annotation.XmlEnumValue("DEBUG")
  36.     DEBUG ("DEBUG"),
  37.     @javax.xml.bind.annotation.XmlEnumValue("INFO")
  38.     INFO ("INFO"),
  39.     @javax.xml.bind.annotation.XmlEnumValue("WARN")
  40.     WARN ("WARN"),
  41.     @javax.xml.bind.annotation.XmlEnumValue("ERROR")
  42.     ERROR ("ERROR"),
  43.     @javax.xml.bind.annotation.XmlEnumValue("FATAL")
  44.     FATAL ("FATAL"),
  45.     @javax.xml.bind.annotation.XmlEnumValue("Sconosciuto")
  46.     SCONOSCIUTO ("Sconosciuto");
  47.    
  48.    
  49.     /** Value */
  50.     private String value;
  51.     @Override
  52.     public String getValue()
  53.     {
  54.         return this.value;
  55.     }


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


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