Art73Type.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 it.gov.fatturapa.sdi.fatturapa.v1_1.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 Art73Type 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 = "Art73Type")
  33. @javax.xml.bind.annotation.XmlEnum(String.class)
  34. public enum Art73Type implements IEnumeration , Serializable , Cloneable {

  35.     @javax.xml.bind.annotation.XmlEnumValue("SI")
  36.     SI ("SI");
  37.    
  38.    
  39.     /** Value */
  40.     private String value;
  41.     @Override
  42.     public String getValue()
  43.     {
  44.         return this.value;
  45.     }


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


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