IDAccordoCooperazione.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 un Accordo di Cooperazione nel registro dei Servizi.
  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 IDAccordoCooperazione implements java.io.Serializable, Cloneable {

  31.      /**
  32.      * serialVersionUID
  33.      */
  34.     private static final long serialVersionUID = 1L;


  35.     /** Nome dell'accordo */
  36.     protected String nome;
  37.     /** Soggetto Referente (Puo' non essere definito). */
  38.     protected IDSoggetto soggettoReferente;
  39.     /** Versione. */
  40.     protected Integer versione = 1;
  41.    

  42.     public String getNome() {
  43.         return this.nome;
  44.     }
  45.     public IDSoggetto getSoggettoReferente() {
  46.         return this.soggettoReferente;
  47.     }
  48.     public Integer getVersione() {
  49.         return this.versione;
  50.     }
  51.    
  52.     @Deprecated
  53.     public void setNome(String nome) {
  54.         this.nome = nome;
  55.     }
  56.     @Deprecated
  57.     public void setSoggettoReferente(IDSoggetto soggettoReferente) {
  58.         this.soggettoReferente = soggettoReferente;
  59.     }
  60.     @Deprecated
  61.     public void setVersione(Integer versione) {
  62.         this.versione = versione;
  63.     }
  64.    
  65.        
  66.     @Override
  67.     public String toString(){
  68.         StringBuilder bf = new StringBuilder();
  69.         if(this.soggettoReferente!=null){
  70.             bf.append(this.soggettoReferente.toString());
  71.             bf.append(":");
  72.         }
  73.         bf.append(this.nome);
  74.         bf.append(":");
  75.         bf.append(this.versione);
  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.         IDAccordoCooperazione id = (IDAccordoCooperazione) 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.         if(this.getVersione()==null) {
  95.             if(id.getVersione()!=null) {
  96.                 return false;
  97.             }
  98.         }
  99.         else {
  100.             if(id.getVersione()==null) {
  101.                 return false;
  102.             }
  103.             if(this.getVersione().intValue()!=id.getVersione().intValue()){
  104.                 return false;
  105.             }
  106.         }
  107.        
  108.         if(this.soggettoReferente==null){
  109.             if(id.soggettoReferente!=null)
  110.                 return false;
  111.         }else{
  112.             if(this.soggettoReferente.equals(id.soggettoReferente)==false)
  113.                 return false;
  114.         }
  115.        
  116.         return true;
  117.     }

  118.     // Utile per usare l'oggetto in hashtable come chiave
  119.     @Override
  120.     public int hashCode(){
  121.         return this.toString().hashCode();
  122.     }

  123.     @Override
  124.     public IDAccordo clone(){
  125.         IDAccordo idAccordo = new IDAccordo();
  126.        
  127.         if(this.nome!=null){
  128.             idAccordo.nome = new String(this.nome);
  129.         }
  130.        
  131.         idAccordo.versione = this.versione;
  132.        
  133.         if(this.soggettoReferente!=null){
  134.             idAccordo.soggettoReferente = this.soggettoReferente.clone();
  135.         }
  136.        
  137.         return idAccordo;
  138.     }
  139.    
  140. }