MessaggioDaNotificare.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.pdd.core.behaviour.built_in.multi_deliver;

  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.  * MessaggiDaNotificare
  27.  *
  28.  * @author Poli Andrea (poli@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */
  32. public enum MessaggioDaNotificare implements IEnumeration , Serializable , Cloneable {

  33.     RICHIESTA ("Richiesta"),
  34.     RISPOSTA ("Risposta"),
  35.     ENTRAMBI ("Entrambi");
  36.    
  37.    
  38.     /** Value */
  39.     private String value;
  40.     @Override
  41.     public String getValue()
  42.     {
  43.         return this.value;
  44.     }


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

  50.    
  51.     @Override
  52.     public String toString(){
  53.         return this.value;
  54.     }
  55.     public boolean equals(String object){
  56.         if(object==null)
  57.             return false;
  58.         return object.equals(this.getValue());  
  59.     }
  60.    
  61.        
  62.    
  63.     /** compatibility with the generated bean (reflection) */
  64.     public boolean equals(Object object,List<String> fieldsNotCheck){
  65.         if( !(object instanceof MessaggioDaNotificare) ){
  66.             throw new RuntimeException("Wrong type: "+object.getClass().getName());
  67.         }
  68.         return this.equals(((MessaggioDaNotificare)object));
  69.     }
  70.     public String toString(boolean reportHTML){
  71.         return toString();
  72.     }
  73.     public String toString(boolean reportHTML,List<String> fieldsNotIncluded){
  74.         return toString();
  75.     }
  76.     public String diff(Object object,StringBuilder bf,boolean reportHTML){
  77.         return bf.toString();
  78.     }
  79.     public String diff(Object object,StringBuilder bf,boolean reportHTML,List<String> fieldsNotIncluded){
  80.         return bf.toString();
  81.     }
  82.    
  83.    
  84.     /** Utilities */
  85.    
  86.     public static String[] toArray(){
  87.         String[] res = new String[values().length];
  88.         int i=0;
  89.         for (MessaggioDaNotificare tmp : values()) {
  90.             res[i]=tmp.getValue();
  91.             i++;
  92.         }
  93.         return res;
  94.     }  
  95.     public static String[] toStringArray(){
  96.         String[] res = new String[values().length];
  97.         int i=0;
  98.         for (MessaggioDaNotificare tmp : values()) {
  99.             res[i]=tmp.toString();
  100.             i++;
  101.         }
  102.         return res;
  103.     }
  104.     public static String[] toEnumNameArray(){
  105.         String[] res = new String[values().length];
  106.         int i=0;
  107.         for (MessaggioDaNotificare tmp : values()) {
  108.             res[i]=tmp.name();
  109.             i++;
  110.         }
  111.         return res;
  112.     }
  113.    
  114.     public static boolean contains(String value){
  115.         return toEnumConstant(value)!=null;
  116.     }
  117.    
  118.     public static MessaggioDaNotificare toEnumConstant(String value){
  119.         try{
  120.             return toEnumConstant(value,false);
  121.         }catch(NotFoundException notFound){
  122.             return null;
  123.         }
  124.     }
  125.     public static MessaggioDaNotificare toEnumConstant(String value, boolean throwNotFoundException) throws NotFoundException{
  126.         MessaggioDaNotificare res = null;
  127.         for (MessaggioDaNotificare tmp : values()) {
  128.             if(tmp.getValue().equals(value)){
  129.                 res = tmp;
  130.                 break;
  131.             }
  132.         }
  133.         if(res==null && throwNotFoundException){
  134.             throw new NotFoundException("Enum with value ["+value+"] not found");
  135.         }
  136.         return res;
  137.     }
  138.    
  139.     public static IEnumeration toEnumConstantFromString(String value){
  140.         try{
  141.             return toEnumConstantFromString(value,false);
  142.         }catch(NotFoundException notFound){
  143.             return null;
  144.         }
  145.     }
  146.     public static IEnumeration toEnumConstantFromString(String value, boolean throwNotFoundException) throws NotFoundException{
  147.         MessaggioDaNotificare res = null;
  148.         for (MessaggioDaNotificare tmp : values()) {
  149.             if(tmp.toString().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. }