117 lines
2.8 KiB
Plaintext
Executable File
117 lines
2.8 KiB
Plaintext
Executable File
package com.fp.hbm.persistence;
|
|
|
|
import java.io.Serializable;
|
|
import java.lang.reflect.Field;
|
|
|
|
import com.fp.dto.hb.HibernateId;
|
|
|
|
/**Clase que hace referencia a la Clave Primaria de THBENTITY*/
|
|
public class TEntityKey1 implements Serializable,Cloneable,HibernateId{
|
|
/**
|
|
* HashCode asociado con la Instancia
|
|
*/
|
|
private volatile int hashValue = 0;
|
|
/**
|
|
* Version de la Clase
|
|
*/
|
|
private static final long serialVersionUID = 1L;
|
|
/**
|
|
* CAMPO TNAME
|
|
*/
|
|
private String tname;
|
|
|
|
/**
|
|
* CAMPO ENTITY
|
|
*/
|
|
private String entity;
|
|
|
|
/**Contructor por defecto*/
|
|
public TEntityKey1(){}
|
|
/**Contructor de TEntityKey
|
|
@param pTname CAMPO TNAME
|
|
@param pEntity CAMPO ENTITY
|
|
*/
|
|
public TEntityKey1(String pTname,String pEntity){
|
|
tname=pTname;
|
|
entity=pEntity;
|
|
}
|
|
/**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;
|
|
}
|
|
|
|
/**Implementación de la comparacion de TEntityKey
|
|
@param o Objeto de comparacion
|
|
*/
|
|
public boolean equals(Object o){
|
|
if (o == null)return false;
|
|
if (! (o instanceof TgeneEntityKey))return false;
|
|
TgeneEntityKey that = (TgeneEntityKey) 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;
|
|
}
|
|
return true;
|
|
}
|
|
/**Implementación del metodo hashCode bajo el patrón de Bloch
|
|
@return hashCode de la instancia TEntityKey
|
|
*/
|
|
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());
|
|
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;
|
|
}
|
|
}
|