重写equals 和 hashCode




import com.acer.agbs.model.MdBin;

public class BinHelper
    extends MdBin {

  
    private static final long serialVersionUID = 1L;

    public BinHelper() {
    super();
    }

    @Override
    public boolean equals(Object obj) {
    if (this == obj)
        return true;
    if (obj == null)
        return false;
    if (getClass() != obj.getClass())
        return false;
    final BinHelper other = (BinHelper) obj;
    if (getAid() == null) {
        if (other.getAid() != null)
        return false;
    } else if (!getAid().equals(other.getAid()))
        return false;
    if (getCode() == null) {
        if (other.getCode() != null)
        return false;
    } else if (!getCode().equals(other.getCode()))
        return false;
    if (getAcWhBusinessPurpose().getDescription() == null) {
        if (other.getAcWhBusinessPurpose().getDescription() != null)
        return false;
    } else if (!getAcWhBusinessPurpose().getDescription().equals(getAcWhBusinessPurpose().getDescription()))
        return false;
    if (getAcTypeWhMaterial().getDescription() == null) {
        if (other.getAcTypeWhMaterial().getDescription() != null)
        return false;
    } else if (!getAcTypeWhMaterial().getDescription().equals(getAcTypeWhMaterial().getDescription()))
        return false;
    return true;
    }

    @Override
    public int hashCode() {
    final int prime = 31;
    int result = 1;
    result = prime * result + ((getAid() == null) ? 0 : getAid().hashCode());
    result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
    result = prime
        * result
        + ((getAcWhBusinessPurpose().getDescription() == null) ? 0 : getAcWhBusinessPurpose().getDescription().hashCode());
    result = prime * result
        + ((getAcTypeWhMaterial().getDescription() == null) ? 0 : getAcTypeWhMaterial().getDescription().hashCode());
    return result;
    }
}

你可能感兴趣的:(重写equals 和 hashCode)