Skip to content

Instantly share code, notes, and snippets.

@mjedynak
Created February 24, 2012 21:19
Show Gist options
  • Save mjedynak/1903807 to your computer and use it in GitHub Desktop.
Save mjedynak/1903807 to your computer and use it in GitHub Desktop.
public class Book {
private String author;
private String title;
private int pages;
public Book(String author, String title, int pages) {
this.author = author;
this.title = title;
this.pages = pages;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Book other = (Book) obj;
return Objects.equals(this.author, other.author) && Objects.equals(this.title, other.title) && Objects.equals(this.pages, other.pages);
}
@Override
public int hashCode() {
return Objects.hash(author, title, pages);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment