Skip to content

Instantly share code, notes, and snippets.

@Sottti
Last active September 22, 2018 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sottti/a41a002cc69d8c1f2959fe1b41913780 to your computer and use it in GitHub Desktop.
Save Sottti/a41a002cc69d8c1f2959fe1b41913780 to your computer and use it in GitHub Desktop.
public class User {
private String name;
private int age;
public User(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@NotNull
@Override
public String toString() {
return this.getClass().getName() +
"(name=" + getName() + ", " +
"age=" + getAge() + ")";
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!User.class.isAssignableFrom(obj.getClass())) {
return false;
}
final User other = (User) obj;
if ((this.name == null) ?
(other.name != null) :
!this.name.equals(other.name)) {
return false;
}
return this.age == other.age;
}
@Override
public int hashCode() {
int hash = 3;
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 53 * hash + this.age;
return hash;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment