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

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