EqualsBuilder HashCodeBuilder equals() and hashCode()

public boolean equals(Object obj) { 
    if (!(obj instanceof CustomerId)) return false; 
    CustomerId other = (CustomerId) obj; 
    return new EqualsBuilder().append(countryCode, other.countryCode) 
      .append(idCardNo, other.idCardNo) 
      .isEquals(); 
  } 
 
  public int hashCode() { 
    return new HashCodeBuilder().append(countryCode) 
      .append(idCardNo).toHashCode(); 
  }

 

你可能感兴趣的:(hashCode())