IDScope.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 Ruolo nel registro dei Servizi.
  24.  *
  25.  * @author Poli Andrea (apoli@link.it)
  26.  * @author $Author$
  27.  * @version $Rev$, $Date$
  28.  */

  29. public class IDScope implements java.io.Serializable, Cloneable {

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

  34.     protected String nome;
  35.    
  36.    
  37.     /* ********  C O S T R U T T O R E  ******** */

  38.    
  39.     /**
  40.      * Costruttore.
  41.      *
  42.      * @param nome Nome del Ruolo
  43.      *
  44.      */
  45.     public IDScope(String nome){
  46.         this.nome = nome;
  47.     }
  48.     /**
  49.      * Costruttore.
  50.      *
  51.      *
  52.      */
  53.     public IDScope(){}




  54.     /* ********  S E T T E R   ******** */

  55.     /**
  56.      * Imposta il nome del Soggetto.
  57.      *
  58.      * @param nome Nome del Soggetto.
  59.      *
  60.      */
  61.     public void setNome(String nome){
  62.         this.nome = nome;
  63.     }
  64.    

  65.    

  66.     /* ********  G E T T E R   ******** */

  67.     /**
  68.      * Ritorna il nome del Soggetto.
  69.      *
  70.      * @return Nome del Soggetto
  71.      *
  72.      */
  73.     public String getNome(){
  74.         return this.nome;
  75.     }


  76.    
  77.    
  78.    
  79.     @Override
  80.     public String toString(){
  81.         return this.nome;
  82.     }
  83.    
  84.     @Override
  85.     public boolean equals(Object object){
  86.         if(object == null)
  87.             return false;
  88.         if(!Utilities.equalsClass(object,this))
  89.             return false;
  90.         IDScope id = (IDScope) object;
  91.         // NOME
  92.         if(this.getNome()==null){
  93.             if(id.getNome()!=null)
  94.                 return false;
  95.         }else{
  96.             if(this.getNome().equals(id.getNome())==false)
  97.                 return false;
  98.         }
  99.        
  100.         return true;
  101.     }
  102.    
  103.     // Utile per usare l'oggetto in hashtable come chiave
  104.     @Override
  105.     public int hashCode(){
  106.         return this.toString().hashCode();
  107.     }
  108.    
  109.     @Override
  110.     public IDScope clone(){
  111.         IDScope clone = new IDScope();
  112.        
  113.         clone.setNome(this.nome!=null ? new String(this.nome) : null);
  114.        
  115.         return clone;
  116.     }
  117. }