Created
August 27, 2014 21:33
-
-
Save longliveenduro/46fe58e8f865d4951521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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