package com.fp.persistence.pgeneral.safe;

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 TSAFEPASSWORD*/
@Embeddable
public class TsafePasswordKey  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="COMPANYCODE", nullable=false,updatable=false)

/**
* Codigo de compania
*/
private Integer companycode;

@Column(name="CHANNELCODE", nullable=false,updatable=false)

/**
* Codigo de canal.
*/
private String channelcode;

/**Contructor por defecto*/
public TsafePasswordKey(){}
/**Contructor de TsafePasswordKey
@param pCompanycode Codigo de compania
@param pChannelcode Codigo de canal.
*/
public TsafePasswordKey(Integer pCompanycode,String pChannelcode){
 companycode=pCompanycode;
 channelcode=pChannelcode;
}
/**Obtiene el valor de companycode
@return valor de companycode*/
public Integer getCompanycode(){
  return companycode;
}
/**Fija el valor de companycode
@param pCompanycode nuevo Valor de companycode*/
public void setCompanycode(Integer pCompanycode){
  companycode=pCompanycode;
}

/**Obtiene el valor de channelcode
@return valor de channelcode*/
public String getChannelcode(){
  return channelcode;
}
/**Fija el valor de channelcode
@param pChannelcode nuevo Valor de channelcode*/
public void setChannelcode(String pChannelcode){
  channelcode=pChannelcode;
}

/**Implementación de la comparación de TsafePasswordKey
@param o Objeto de comparación
*/
public boolean equals(Object o){
  if (o == null)return false;
  if (! (o instanceof TsafePasswordKey))return false;
  TsafePasswordKey that = (TsafePasswordKey) o;
  if (this.getCompanycode() == null || that.getCompanycode() == null){
      return false;
  }
  if (! this.getCompanycode().equals(that.getCompanycode())){
    return false;
  }
  if (this.getChannelcode() == null || that.getChannelcode() == null){
      return false;
  }
  if (! this.getChannelcode().equals(that.getChannelcode())){
    return false;
  }
  return true;
}
/**Implementación del método hashCode bajo el patrón de Bloch
@return hashCode de la instancia TsafePasswordKey
*/
public int hashCode(){
  if (this.hashValue == 0){
    int result = 17;
    result = result * 37 + (this.getCompanycode() == null ? 0 : this.getCompanycode().hashCode());
    result = result * 37 + (this.getChannelcode() == null ? 0 : this.getChannelcode().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;
	}
}
