Skip to content

Instantly share code, notes, and snippets.

@krisskross
Created May 18, 2012 16:50
Show Gist options
  • Save krisskross/2726357 to your computer and use it in GitHub Desktop.
Save krisskross/2726357 to your computer and use it in GitHub Desktop.
public class Item {
private String id;
private String name;
public Item(String id, String name) {
this.id = id;
this.id = name;
}
public String getId() { return id;}
public String getName() { return name; }
@Override
public int hashCode() {
return Objects.hashCode(getId(), getName());
}
@Override
public String toString() {
return Objects.toStringHelper(this).add("id", getId()).add("name", getName()).toString();
}
@Override
public boolean equals(Object o) {
if (!(o instanceof Item)) {
return false;
}
Item other = (Item) o;
return Objects.equal(getId(), other.getId();
Objects.equal(getName(), other.getName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment