Last active
September 22, 2018 08:02
-
-
Save Sottti/a41a002cc69d8c1f2959fe1b41913780 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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