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

  35.     @javax.xml.bind.annotation.XmlEnumValue("TRANSAZIONE")
  36.     TRANSAZIONE ("TRANSAZIONE"),
  37.     @javax.xml.bind.annotation.XmlEnumValue("RICERCA")
  38.     RICERCA ("RICERCA"),
  39.     @javax.xml.bind.annotation.XmlEnumValue("STATISTICA")
  40.     STATISTICA ("STATISTICA"),
  41.     @javax.xml.bind.annotation.XmlEnumValue("ALLARME")
  42.     ALLARME ("ALLARME"),
  43.     @javax.xml.bind.annotation.XmlEnumValue("CONNETTORE")
  44.     CONNETTORE ("CONNETTORE"),
  45.     @javax.xml.bind.annotation.XmlEnumValue("AUTENTICAZIONE")
  46.     AUTENTICAZIONE ("AUTENTICAZIONE"),
  47.     @javax.xml.bind.annotation.XmlEnumValue("AUTORIZZAZIONE")
  48.     AUTORIZZAZIONE ("AUTORIZZAZIONE"),
  49.     @javax.xml.bind.annotation.XmlEnumValue("AUTORIZZAZIONE_CONTENUTI")
  50.     AUTORIZZAZIONE_CONTENUTI ("AUTORIZZAZIONE_CONTENUTI"),
  51.     @javax.xml.bind.annotation.XmlEnumValue("INTEGRAZIONE")
  52.     INTEGRAZIONE ("INTEGRAZIONE"),
  53.     @javax.xml.bind.annotation.XmlEnumValue("MESSAGE_HANDLER")
  54.     MESSAGE_HANDLER ("MESSAGE_HANDLER"),
  55.     @javax.xml.bind.annotation.XmlEnumValue("SERVICE_HANDLER")
  56.     SERVICE_HANDLER ("SERVICE_HANDLER"),
  57.     @javax.xml.bind.annotation.XmlEnumValue("BEHAVIOUR")
  58.     BEHAVIOUR ("BEHAVIOUR"),
  59.     @javax.xml.bind.annotation.XmlEnumValue("RATE_LIMITING")
  60.     RATE_LIMITING ("RATE_LIMITING"),
  61.     @javax.xml.bind.annotation.XmlEnumValue("TOKEN_DYNAMIC_DISCOVERY")
  62.     TOKEN_DYNAMIC_DISCOVERY ("TOKEN_DYNAMIC_DISCOVERY"),
  63.     @javax.xml.bind.annotation.XmlEnumValue("TOKEN_VALIDAZIONE")
  64.     TOKEN_VALIDAZIONE ("TOKEN_VALIDAZIONE"),
  65.     @javax.xml.bind.annotation.XmlEnumValue("TOKEN_NEGOZIAZIONE")
  66.     TOKEN_NEGOZIAZIONE ("TOKEN_NEGOZIAZIONE"),
  67.     @javax.xml.bind.annotation.XmlEnumValue("ATTRIBUTE_AUTHORITY")
  68.     ATTRIBUTE_AUTHORITY ("ATTRIBUTE_AUTHORITY");
  69.    
  70.    
  71.     /** Value */
  72.     private String value;
  73.     @Override
  74.     public String getValue()
  75.     {
  76.         return this.value;
  77.     }


  78.     /** Official Constructor */
  79.     TipoPlugin(String value)
  80.     {
  81.         this.value = value;
  82.     }


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