Implement hashCode using commons-lang : Class Helper « Apache Common « Java

Implement hashCode using commons-lang

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


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);



Related examples in the same category

1.Use CompareToBuilder class to create compareTo method for your own class
2.Use Reflection To build toString method
3.Implement equals method using commons-lang
4.Jakarta Commons toString Builder