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

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


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


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