IdentificativiFruizione.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.  * IdentificativiFruizione
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */
  29. public class IdentificativiFruizione implements java.io.Serializable, Cloneable {

  30.     /**
  31.      *
  32.      */
  33.     private static final long serialVersionUID = 1L;
  34.    
  35.     private IDSoggetto soggettoFruitore;
  36.     private IDServizio idServizio;
  37.    
  38.     public IDSoggetto getSoggettoFruitore() {
  39.         return this.soggettoFruitore;
  40.     }
  41.     public void setSoggettoFruitore(IDSoggetto soggettoFruitore) {
  42.         this.soggettoFruitore = soggettoFruitore;
  43.     }
  44.     public IDServizio getIdServizio() {
  45.         return this.idServizio;
  46.     }
  47.     public void setIdServizio(IDServizio idServizio) {
  48.         this.idServizio = idServizio;
  49.     }
  50.    
  51.    
  52.     @Override
  53.     public String toString(){
  54.         StringBuilder bf = new StringBuilder();
  55.         if(this.soggettoFruitore!=null)
  56.             bf.append("SoggettoFruitore:"+this.soggettoFruitore);
  57.         else
  58.             bf.append("SoggettoFruitore:NonDefinita");
  59.         bf.append(" ");
  60.         if(this.idServizio!=null)
  61.             bf.append("Servizio:"+this.idServizio.toString());
  62.         else
  63.             bf.append("Servizio:NonDefinito");
  64.         return bf.toString();
  65.     }
  66.    
  67.     @Override
  68.     public boolean equals(Object object){
  69.         if(object == null)
  70.             return false;
  71.         if(!Utilities.equalsClass(object,this))
  72.             return false;
  73.         IdentificativiFruizione id = (IdentificativiFruizione) object;
  74.        
  75.         if(this.soggettoFruitore==null){
  76.             if(id.soggettoFruitore!=null)
  77.                 return false;
  78.         }else{
  79.             if(this.soggettoFruitore.equals(id.soggettoFruitore)==false)
  80.                 return false;
  81.         }
  82.        
  83.         if(this.idServizio==null){
  84.             if(id.idServizio!=null)
  85.                 return false;
  86.         }else{
  87.             if(this.idServizio.equals(id.idServizio)==false)
  88.                 return false;
  89.         }
  90.        
  91.         return true;
  92.     }
  93.    
  94.     // Utile per usare l'oggetto in hashtable come chiave
  95.     @Override
  96.     public int hashCode(){
  97.         return this.toString().hashCode();
  98.     }
  99.    
  100.     @Override
  101.     public IdentificativiFruizione clone(){
  102.         IdentificativiFruizione id = new IdentificativiFruizione();
  103.         if(this.soggettoFruitore!=null){
  104.             id.soggettoFruitore = this.soggettoFruitore.clone();
  105.         }
  106.         if(this.idServizio!=null){
  107.             id.idServizio = this.idServizio.clone();
  108.         }
  109.         return id;
  110.     }
  111. }