Last active
August 8, 2018 19:51
-
-
Save drulabs/22c9d006824fae0f8526cdde4c42bd9d 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
// Java POJO | |
public class Person { | |
private String name; | |
private int age; | |
private char gender; | |
public Person(String name, int age, char gender) { | |
this.name = name; | |
this.age = age; | |
this.gender = gender; | |
} | |
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; } | |
public char getGender() { return gender; } | |
public void setGender(char gender) { this.gender = gender; } | |
@Override | |
public boolean equals(Object o) { | |
if (this == o) return true; | |
if (o == null || getClass() != o.getClass()) return false; | |
Person person = (Person) o; | |
return age == person.age && | |
gender == person.gender && | |
Objects.equals(name, person.name); | |
} | |
@Override | |
public int hashCode() { | |
return Objects.hash(name, age, gender); | |
} | |
@Override | |
public String toString() { | |
return "Person(" + | |
"name='" + name + '\'' + | |
", age=" + age + | |
", gender=" + gender + | |
')'; | |
} | |
} |
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
// Kotlin Data class | |
data class Person(val name: String, val age: Int, val gender: Char) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment