maia/.svn/pristine/7c/7c17a1a9241064f46997e0addfe...

152 lines
3.8 KiB
Plaintext
Executable File

package com.fp.hbm.persistence;
import java.io.Serializable;
import java.lang.reflect.Field;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Transient;
import com.fp.dto.hb.HibernateId;
/**Clase que hace referencia a la Clave Primaria de THBFIELDS*/
@Embeddable
public class TgeneFieldsKey implements Serializable,Cloneable,HibernateId{
/**
* HashCode asociado con la Instancia
*/
@Transient
private int hashValue = 0;
/**
* Version de la Clase
*/
private static final long serialVersionUID = 1L;
/**
* CAMPO TNAME
*/
@Column(name="TNAME", nullable=false,updatable=false)
private String tname;
/**
* CAMPO ENTITY
*/
@Column(name="ENTITY", nullable=false,updatable=false)
private String entity;
/**
* CAMPO FIELD
*/
@Column(name="FIELD", nullable=false,updatable=false)
private String field;
/**Contructor por defecto*/
public TgeneFieldsKey(){}
/**Contructor de TFieldsKey
@param pTname CAMPO TNAME
@param pEntity CAMPO ENTITY
@param pField CAMPO FIELD
*/
public TgeneFieldsKey(String pTname,String pEntity,String pField){
tname=pTname;
entity=pEntity;
field=pField;
}
/**Obtiene el valor de tname
@return valor de tname*/
public String getTname(){
return tname;
}
/**Fija el valor de tname
@param pTname nuevo Valor de tname*/
public void setTname(String pTname){
tname=pTname;
}
/**Obtiene el valor de entity
@return valor de entity*/
public String getEntity(){
return entity;
}
/**Fija el valor de entity
@param pEntity nuevo Valor de entity*/
public void setEntity(String pEntity){
entity=pEntity;
}
/**Obtiene el valor de field
@return valor de field*/
public String getField(){
return field;
}
/**Fija el valor de field
@param pField nuevo Valor de field*/
public void setField(String pField){
field=pField;
}
/**Implementación de la comparacion de TFieldsKey
@param o Objeto de comparacion
*/
public boolean equals(Object o){
if (o == null)return false;
if (! (o instanceof TgeneFieldsKey))return false;
TgeneFieldsKey that = (TgeneFieldsKey) o;
if (this.getTname() == null || that.getTname() == null){
return false;
}
if (! this.getTname().equals(that.getTname())){
return false;
}
if (this.getEntity() == null || that.getEntity() == null){
return false;
}
if (! this.getEntity().equals(that.getEntity())){
return false;
}
if (this.getField() == null || that.getField() == null){
return false;
}
if (! this.getField().equals(that.getField())){
return false;
}
return true;
}
/**Implementación del metodo hashCode bajo el patrón de Bloch
@return hashCode de la instancia TFieldsKey
*/
public int hashCode(){
if (this.hashValue == 0){
int result = 17;
result = result * 37 + (this.getTname() == null ? 0 : this.getTname().hashCode());
result = result * 37 + (this.getEntity() == null ? 0 : this.getEntity().hashCode());
result = result * 37 + (this.getField() == null ? 0 : this.getField().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;
}
}