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

  35.     @javax.xml.bind.annotation.XmlEnumValue("soap11")
  36.     SOAP_11 ("soap11"),
  37.     @javax.xml.bind.annotation.XmlEnumValue("soap12")
  38.     SOAP_12 ("soap12"),
  39.     @javax.xml.bind.annotation.XmlEnumValue("xml")
  40.     XML ("xml"),
  41.     @javax.xml.bind.annotation.XmlEnumValue("json")
  42.     JSON ("json"),
  43.     @javax.xml.bind.annotation.XmlEnumValue("none")
  44.     NONE ("none");
  45.    
  46.    
  47.     /** Value */
  48.     private String value;
  49.     @Override
  50.     public String getValue()
  51.     {
  52.         return this.value;
  53.     }


  54.     /** Official Constructor */
  55.     DefaultIntegrationErrorMessageType(String value)
  56.     {
  57.         this.value = value;
  58.     }


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