MultitenantSoggettiFruizioni.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.web.ctrlstat.costanti;

  21. import java.util.List;

  22. import org.openspcoop2.generic_project.exception.NotFoundException;

  23. /**
  24. *
  25. * TipoOggettoDaSmistare
  26. *
  27. * @author Andrea Poli (apoli@link.it)
  28. * @author $Author$
  29. * @version $Rev$, $Date$
  30. *
  31. */
  32. public enum MultitenantSoggettiFruizioni {

  33.     SOLO_SOGGETTI_ESTERNI("Solo Soggetti Esterni"),
  34.     ESCLUDI_SOGGETTO_FRUITORE("Escludi Soggetto Fruitore"),
  35.     TUTTI("Tutti");
  36.    
  37.     /** Value */
  38.     private String value;
  39.     public String getValue()
  40.     {
  41.         return this.value;
  42.     }


  43.     /** Official Constructor */
  44.     MultitenantSoggettiFruizioni(String value)
  45.     {
  46.         this.value = value;
  47.     }


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

  136. }