IDGenericProperties.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 gruppo di proprietà
  24.  *
  25.  *
  26.  * @author Poli Andrea (apoli@link.it)
  27.  * @author Nardi Lorenzo (nardi@link.it)
  28.  * @author $Author$
  29.  * @version $Rev$, $Date$
  30.  */

  31. public class IDGenericProperties implements java.io.Serializable, Cloneable {

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


  36.     /** Nome del gruppo di proprieta */
  37.     protected String nome;
  38.     /** Tipologia del gruppo di proprieta */
  39.     protected String tipologia;


  40.     public String getNome() {
  41.         return this.nome;
  42.     }
  43.     public String getTipologia() {
  44.         return this.tipologia;
  45.     }
  46.    
  47.     public void setNome(String nome) {
  48.         this.nome = nome;
  49.     }
  50.     public void setTipologia(String tipologia) {
  51.         this.tipologia = tipologia;
  52.     }
  53.    
  54.        
  55.     @Override
  56.     public String toString(){
  57.         StringBuilder bf = new StringBuilder();
  58.         bf.append(this.tipologia);
  59.         bf.append(":");
  60.         bf.append(this.nome);
  61.         return bf.toString();
  62.     }
  63.        
  64.     @Override
  65.     public boolean equals(Object object){
  66.         if(object == null)
  67.             return false;
  68.         if(!Utilities.equalsClass(object,this))
  69.             return false;
  70.         IDGenericProperties id = (IDGenericProperties) object;
  71.        
  72.         if(this.tipologia==null){
  73.             if(id.tipologia!=null)
  74.                 return false;
  75.         }else{
  76.             if(this.tipologia.equals(id.tipologia)==false)
  77.                 return false;
  78.         }

  79.         if(this.nome==null){
  80.             if(id.nome!=null)
  81.                 return false;
  82.         }else{
  83.             if(this.nome.equals(id.nome)==false)
  84.                 return false;
  85.         }
  86.        
  87.         return true;
  88.     }

  89.     // Utile per usare l'oggetto in hashtable come chiave
  90.     @Override
  91.     public int hashCode(){
  92.         return this.toString().hashCode();
  93.     }

  94.     @Override
  95.     public IDGenericProperties clone(){
  96.         IDGenericProperties idGP = new IDGenericProperties();
  97.        
  98.         if(this.nome!=null){
  99.             idGP.nome = new String(this.nome);
  100.         }
  101.        
  102.         if(this.tipologia!=null){
  103.             idGP.tipologia = new String(this.tipologia);
  104.         }
  105.        
  106.         return idGP;
  107.     }
  108. }