IDPortaApplicativa.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.id;

  21. import org.openspcoop2.utils.Utilities;

  22. /**
  23.  * Classe utilizzata per rappresentare un identificatore di una Porta Applicativa nella configurazione
  24.  *
  25.  * </pre>
  26.  *
  27.  * @author Poli Andrea (apoli@link.it)
  28.  * @author Nardi Lorenzo (nardi@link.it)
  29.  * @author $Author$
  30.  * @version $Rev$, $Date$
  31.  */

  32. public class IDPortaApplicativa implements java.io.Serializable, Cloneable{
  33.    
  34.      /**
  35.      * serialVersionUID
  36.      */
  37.     private static final long serialVersionUID = 1L;
  38.    
  39.    
  40.     /** Nome della Porta Applicativa */
  41.     private String nome;
  42.        
  43.     /** Identificazioni Erogazione (opzionali) */
  44.     private IdentificativiErogazione identificativiErogazione;
  45.    
  46.    
  47.    
  48.     public String getNome() {
  49.         return this.nome;
  50.     }
  51.     public void setNome(String nome) {
  52.         this.nome = nome;
  53.     }

  54.     public IdentificativiErogazione getIdentificativiErogazione() {
  55.         return this.identificativiErogazione;
  56.     }
  57.     public void setIdentificativiErogazione(IdentificativiErogazione identificativiErogazione) {
  58.         this.identificativiErogazione = identificativiErogazione;
  59.     }
  60.    
  61.     public static final String PORTA_APPLICATIVA_PREFIX = "PA:";
  62.     public static final String PORTA_APPLICATIVA_SUFFIX = " ";
  63.    
  64.     @Override
  65.     public String toString(){
  66.         StringBuilder bf = new StringBuilder();
  67.         if(this.nome!=null)
  68.             bf.append(PORTA_APPLICATIVA_PREFIX+this.nome);
  69.         else
  70.             bf.append(PORTA_APPLICATIVA_PREFIX+"NonDefinita");
  71.         bf.append(PORTA_APPLICATIVA_SUFFIX);
  72.         if(this.identificativiErogazione!=null)
  73.             bf.append("Erogazione:"+this.identificativiErogazione.toString());
  74.         else
  75.             bf.append("Erogazione:NonDefinita");
  76.         return bf.toString();
  77.     }
  78.    
  79.     @Override
  80.     public boolean equals(Object object){
  81.         if(object == null)
  82.             return false;
  83.         if(!Utilities.equalsClass(object,this))
  84.             return false;
  85.         IDPortaApplicativa id = (IDPortaApplicativa) object;
  86.        
  87.         if(this.nome==null){
  88.             if(id.nome!=null)
  89.                 return false;
  90.         }else{
  91.             if(this.nome.equals(id.nome)==false)
  92.                 return false;
  93.         }
  94.        
  95.         return true;
  96.     }
  97.    
  98.     // Utile per usare l'oggetto in hashtable come chiave
  99.     @Override
  100.     public int hashCode(){
  101.         return this.toString().hashCode();
  102.     }
  103.    
  104.     @Override
  105.     public IDPortaApplicativa clone(){
  106.         IDPortaApplicativa idPA = new IDPortaApplicativa();
  107.         if(this.nome!=null){
  108.             idPA.nome = new String(this.nome);
  109.         }
  110.         if(this.identificativiErogazione!=null){
  111.             idPA.identificativiErogazione = this.identificativiErogazione.clone();
  112.         }
  113.         return idPA;
  114.     }
  115. }