InterfaceType.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.lib.users.dao;


  21. /**
  22.  * InterfaceType
  23.  *
  24.  * @author Andrea Poli (apoli@link.it)
  25.  * @author Stefano Corallo (corallo@link.it)
  26.  * @author Sandra Giangrandi (sandra@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  *
  30.  */
  31. public enum InterfaceType {
  32.     COMPLETA,AVANZATA,STANDARD;
  33.    
  34.     public static InterfaceType convert(String type, boolean throwNotFound) throws Exception {
  35.         if(InterfaceType.AVANZATA.toString().equals(type)){
  36.             return InterfaceType.AVANZATA;
  37.         }
  38.         else if(InterfaceType.STANDARD.toString().equals(type)){
  39.             return InterfaceType.STANDARD;
  40.         }
  41.         else if(InterfaceType.COMPLETA.toString().equals(type)){
  42.             return InterfaceType.COMPLETA;
  43.         }
  44.         if(throwNotFound) {
  45.             throw new Exception("Tipo ["+type+"] sconosciuto");
  46.         }
  47.         return null;
  48.     }
  49.    
  50.     public static boolean equals(InterfaceType src, InterfaceType ... check) {
  51.         if(src==null) {
  52.             return false;
  53.         }
  54.         return src.equalsOr(check);
  55.     }
  56.        
  57.     public boolean equalsOr(InterfaceType ... check) {
  58.         if(check==null || check.length<=0) {
  59.             return false;
  60.         }
  61.         for (int i = 0; i < check.length; i++) {
  62.             if(this.equals(check[i])) {
  63.                 return true;
  64.             }
  65.         }
  66.         return false;
  67.     }
  68.    
  69.     public boolean equals(String object){
  70.         if(object==null)
  71.             return false;
  72.         return object.equals(this.name());  
  73.     }
  74. }