IDSoggettoDB.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.registry.driver.db;

  21. import java.io.Serializable;

  22. import org.openspcoop2.core.id.IDSoggetto;

  23. /**
  24.  * Classe utilizzata per rappresentare un identificatore di un Soggetto nel Registro
  25.  *
  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 IDSoggettoDB extends IDSoggetto implements Serializable {

  33.     /**
  34.      *
  35.      */
  36.     private static final long serialVersionUID = 1L;

  37.     private Long id;

  38.     public Long getId() {
  39.         return this.id;
  40.     }

  41.     public void setId(Long id) {
  42.         this.id = id;
  43.     }
  44.    
  45.     public IDSoggettoDB() {
  46.        
  47.     }
  48.     public IDSoggettoDB(String tipoSoggetto, String nomeSoggetto) {
  49.         super.setNome(nomeSoggetto);
  50.         super.setTipo(tipoSoggetto);
  51.     }
  52.     public IDSoggettoDB(IDSoggetto idSoggetto) {
  53.         super.setNome(idSoggetto.getNome());
  54.         super.setTipo(idSoggetto.getTipo());
  55.         super.setCodicePorta(idSoggetto.getCodicePorta());
  56.     }

  57.     @Override
  58.     public String toString(){
  59.         StringBuilder bf = new StringBuilder();
  60.         bf.append(super.toString());
  61.         bf.append(" ");
  62.         if(this.id!=null)
  63.             bf.append("Id:"+this.id);
  64.         else
  65.             bf.append("Id");
  66.         return bf.toString();
  67.     }
  68.    
  69.     @Override
  70.     public boolean equals(Object object){
  71.         return super.equalsEngine(object, false);
  72.     }
  73.    
  74.     // Utile per usare l'oggetto in hashtable come chiave
  75.     @Override
  76.     public int hashCode(){
  77.         return this.toString().hashCode();
  78.     }
  79.    
  80.     @Override
  81.     public IDSoggettoDB clone(){
  82.         IDSoggettoDB idSoggetto = new IDSoggettoDB();
  83.         if(this.getNome()!=null){
  84.             idSoggetto.setNome(new String(this.getNome()));
  85.         }
  86.         if(this.getTipo()!=null){
  87.             idSoggetto.setTipo(new String(this.getTipo()));
  88.         }
  89.         if(this.getCodicePorta()!=null){
  90.             idSoggetto.setCodicePorta(new String(this.getCodicePorta()));
  91.         }
  92.         if(this.id!=null){
  93.             idSoggetto.setId(Long.valueOf(this.id+""));
  94.         }
  95.         return idSoggetto;
  96.     }
  97. }