package com.fp.persistence.pgeneral.dict; import javax.persistence.Column; import java.io.Serializable; import com.fp.dto.hb.HibernateId; import java.lang.reflect.Field; import javax.persistence.Embeddable; import javax.persistence.Transient; /**Clase que hace referencia a la Clave Primaria de TGENEDICTIONARY*/ @Embeddable public class TgeneDictionaryKey extends com.fp.dto.AbstractDataTransport implements Serializable,Cloneable,HibernateId{ /** * HashCode asociado con la Instancia */ @Transient private int hashValue = 0; /** * Version de la Clase */ private static final long serialVersionUID = 1L; @Column(name="TABLENAME", nullable=false,updatable=false) /** * Nombre de la tabla asociada al diccionario */ private String tablename; @Column(name="COLUMNNAME", nullable=false,updatable=false) /** * Nombre de la columna que almacena condiciones especiales. */ private String columnname; /**Contructor por defecto*/ public TgeneDictionaryKey(){} /**Contructor de TgeneDictionaryKey @param pTablename Nombre de la tabla asociada al diccionario @param pColumnname Nombre de la columna que almacena condiciones especiales. */ public TgeneDictionaryKey(String pTablename,String pColumnname){ tablename=pTablename; columnname=pColumnname; } /**Obtiene el valor de tablename @return valor de tablename*/ public String getTablename(){ return tablename; } /**Fija el valor de tablename @param pTablename nuevo Valor de tablename*/ public void setTablename(String pTablename){ tablename=pTablename; } /**Obtiene el valor de columnname @return valor de columnname*/ public String getColumnname(){ return columnname; } /**Fija el valor de columnname @param pColumnname nuevo Valor de columnname*/ public void setColumnname(String pColumnname){ columnname=pColumnname; } /**Implementación de la comparación de TgeneDictionaryKey @param o Objeto de comparación */ public boolean equals(Object o){ if (o == null)return false; if (! (o instanceof TgeneDictionaryKey))return false; TgeneDictionaryKey that = (TgeneDictionaryKey) o; if (this.getTablename() == null || that.getTablename() == null){ return false; } if (! this.getTablename().equals(that.getTablename())){ return false; } if (this.getColumnname() == null || that.getColumnname() == null){ return false; } if (! this.getColumnname().equals(that.getColumnname())){ return false; } return true; } /**Implementación del método hashCode bajo el patrón de Bloch @return hashCode de la instancia TgeneDictionaryKey */ public int hashCode(){ if (this.hashValue == 0){ int result = 17; result = result * 37 + (this.getTablename() == null ? 0 : this.getTablename().hashCode()); result = result * 37 + (this.getColumnname() == null ? 0 : this.getColumnname().hashCode()); this.hashValue = result; } return this.hashValue; } public Object cloneMe() throws CloneNotSupportedException { return this.clone(); } /**Implementación toString */ public String toString() { Field[]fs=this.getClass().getDeclaredFields(); String data=""; for(Field f:fs){ try{ String name=f.getName(); if(f.getType().getName().compareTo("java.util.Set")==0)continue; if(name.compareTo("hashValue")==0||name.compareTo("serialVersionUID")==0)continue; data+="pk."+name+"="+f.get(this)+";"; }catch(Exception e){ continue; } } if(data.compareTo("")==0){ data=super.toString(); } return data; } }