IDPortaDelegata.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 Delegata nella configurazione
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author Nardi Lorenzo (nardi@link.it)
  27.  * @author $Author$
  28.  * @version $Rev$, $Date$
  29.  */

  30. public class IDPortaDelegata implements java.io.Serializable, Cloneable{

  31.      /**
  32.      * serialVersionUID
  33.      */
  34.     private static final long serialVersionUID = 1L;
  35.    
  36.     /** Nome della Porta Delegata */
  37.     private String nome;
  38.        
  39.     /** Identificazioni Fruizione (opzionali) */
  40.     private IdentificativiFruizione identificativiFruizione;

  41.    
  42.     public String getNome() {
  43.         return this.nome;
  44.     }
  45.     public void setNome(String nome) {
  46.         this.nome = nome;
  47.     }

  48.     public IdentificativiFruizione getIdentificativiFruizione() {
  49.         return this.identificativiFruizione;
  50.     }
  51.     public void setIdentificativiFruizione(IdentificativiFruizione identificativiFruizione) {
  52.         this.identificativiFruizione = identificativiFruizione;
  53.     }

  54.    
  55.     public static final String PORTA_DELEGATA_PREFIX = "PD:";
  56.     public static final String PORTA_DELEGATA_SUFFIX = " ";

  57.     @Override
  58.     public String toString(){
  59.         StringBuilder bf = new StringBuilder();
  60.         if(this.nome!=null)
  61.             bf.append(PORTA_DELEGATA_PREFIX+this.nome);
  62.         else
  63.             bf.append(PORTA_DELEGATA_PREFIX+"NonDefinita");
  64.         bf.append(PORTA_DELEGATA_SUFFIX);
  65.         if(this.identificativiFruizione!=null)
  66.             bf.append("Fruizione:"+this.identificativiFruizione.toString());
  67.         else
  68.             bf.append("Fruizione:NonDefinita");
  69.         return bf.toString();
  70.     }
  71.    
  72.     @Override
  73.     public boolean equals(Object object){
  74.         if(object == null)
  75.             return false;
  76.         if(!Utilities.equalsClass(object,this))
  77.             return false;
  78.         IDPortaDelegata id = (IDPortaDelegata) object;
  79.        
  80.         if(this.nome==null){
  81.             if(id.nome!=null)
  82.                 return false;
  83.         }else{
  84.             if(this.nome.equals(id.nome)==false)
  85.                 return false;
  86.         }
  87.        
  88.         return true;
  89.     }
  90.    
  91.     // Utile per usare l'oggetto in hashtable come chiave
  92.     @Override
  93.     public int hashCode(){
  94.         return this.toString().hashCode();
  95.     }
  96.    
  97.     @Override
  98.     public IDPortaDelegata clone(){
  99.         IDPortaDelegata idPD = new IDPortaDelegata();
  100.         if(this.nome!=null){
  101.             idPD.nome = new String(this.nome);
  102.         }
  103.         if(this.identificativiFruizione!=null){
  104.             idPD.identificativiFruizione = this.identificativiFruizione.clone();
  105.         }
  106.         return idPD;
  107.     }
  108. }