ProfiloDiCollaborazione.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.protocol.sdk.constants;

  21. import org.apache.commons.lang.NotImplementedException;

  22. /**
  23.  * ProfiliDiCollaborazione
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public enum ProfiloDiCollaborazione {
  30.     ONEWAY("Oneway"),
  31.     SINCRONO("Sincrono"),
  32.     ASINCRONO_SIMMETRICO("AsincronoSimmetrico"),
  33.     ASINCRONO_ASIMMETRICO("AsincronoAsimmetrico"),
  34.     UNKNOWN("Sconosciuto");
  35.    
  36.     private final String profilo;

  37.     ProfiloDiCollaborazione(String profilo){
  38.         this.profilo = profilo;
  39.     }
  40.    
  41.     @Override
  42.     public String toString() {
  43.         throw new NotImplementedException("Use ProtocolFactory.createTraduttore().toString(profilo) or getEngineValue()");
  44.     }
  45.    
  46.     public boolean equals(String p){
  47.         if(p==null){
  48.             return false;
  49.         }
  50.         return this.profilo.equals(p);
  51.     }
  52.    
  53.     public String getEngineValue(){
  54.         return this.profilo;
  55.     }
  56.    
  57.     public static ProfiloDiCollaborazione toProfiloDiCollaborazione(String p){
  58.         if(ONEWAY.getEngineValue().equals(p))
  59.             return ONEWAY;
  60.         if(SINCRONO.getEngineValue().equals(p))
  61.             return SINCRONO;
  62.         if(ASINCRONO_ASIMMETRICO.getEngineValue().equals(p))
  63.             return ASINCRONO_ASIMMETRICO;
  64.         if(ASINCRONO_SIMMETRICO.getEngineValue().equals(p))
  65.             return ASINCRONO_SIMMETRICO;
  66.         return UNKNOWN;
  67.     }


  68. }