Skip to content

Instantly share code, notes, and snippets.

@longliveenduro
Created August 27, 2014 21:33
Show Gist options
  • Save longliveenduro/46fe58e8f865d4951521 to your computer and use it in GitHub Desktop.
Save longliveenduro/46fe58e8f865d4951521 to your computer and use it in GitHub Desktop.
public class User {
private int id;
private String name;
public int getId() {
return id;
}
public String getName() {
return name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
User user = (User) o;
if (id != user.id) return false;
if (name != null ? !name.equals(user.name) : user.name != null) return false;
return true;
}
@Override
public int hashCode() {
int result = id;
result = 31 * result + (name != null ? name.hashCode() : 0);
return result;
}
@Override
public String toString() {
return "User{" +
"id=" + id +
", name='" + name + '\'' +
'}';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment