Implement hashCode using commons-lang : hashCode « Class Definition « Java Tutorial






import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;

import java.io.Serializable;

public class Main implements Serializable {
  private Long id;

  private String title;

  private String author;

  public int hashCode() {
    return new HashCodeBuilder().append(id).append(title).append(author).toHashCode();

    // return HashCodeBuilder.reflectionHashCode(this);

  }
}








5.34.hashCode
5.34.1.Implement hashCode using commons-lang
5.34.2.Comparing Object Values Using Hash Codes
5.34.3.Get the identity hash codes
5.34.4.Null Safe Hash Code
5.34.5.Secure Hash
5.34.6.Get hash code for primitive data types
5.34.7.A very efficient java hash algorithm, based on the BuzHash algoritm
5.34.8.Computing hash codes
5.34.9.Returns an integer hash code representing the given double array value.