TipoAPI.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.transazioni.constants;

  21. import java.io.Serializable;


  22. /**    
  23.  * TipoAPI
  24.  *
  25.  * @author Poli Andrea (poli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum TipoAPI implements Serializable{

  30.     REST ("1"),
  31.     SOAP ("2");

  32.     private final String valore;

  33.     TipoAPI(String valore)
  34.     {
  35.         this.valore = valore;
  36.     }

  37.     public String getValore()
  38.     {
  39.         return this.valore;
  40.     }

  41.     public int getValoreAsInt()
  42.     {
  43.         return Integer.parseInt(this.valore);
  44.     }

  45.     public static String[] toStringArray(){
  46.         String[] res = new String[values().length];
  47.         int i=0;
  48.         for (TipoAPI tmp : values()) {
  49.             res[i]=tmp.getValore();
  50.             i++;
  51.         }
  52.         return res;
  53.     }
  54.     public static int[] toIntArray(){
  55.         int[] res = new int[values().length];
  56.         int i=0;
  57.         for (TipoAPI tmp : values()) {
  58.             res[i]=tmp.getValoreAsInt();
  59.             i++;
  60.         }
  61.         return res;
  62.     }
  63.     public static String[] toEnumNameArray(){
  64.         String[] res = new String[values().length];
  65.         int i=0;
  66.         for (TipoAPI tmp : values()) {
  67.             res[i]=tmp.name();
  68.             i++;
  69.         }
  70.         return res;
  71.     }


  72.     public static TipoAPI toEnumConstant(int val){
  73.         return toEnumConstant(""+val);
  74.     }
  75.     public static TipoAPI toEnumConstant(String val){

  76.         TipoAPI res = null;

  77.         if(TipoAPI.REST.toString().equals(val)){
  78.             res = TipoAPI.REST;
  79.         }else if(TipoAPI.SOAP.toString().equals(val)){
  80.             res = TipoAPI.SOAP;
  81.         }
  82.         return res;
  83.     }

  84.    
  85.     @Override
  86.     public String toString(){
  87.         return this.valore;
  88.     }



  89. }