Skip to content

Instantly share code, notes, and snippets.

@yfklon

yfklon/SimplePojo.java Secret

Last active Mar 18, 2020
Embed
What would you like to do?
Immutable pojo class.
import java.util.Objects;
public final class SimplePojo {
private final String name;
private final String surname;
public SimplePojo(String name, String surname) {
this.name = name;
this.surname = surname;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SimplePojo that = (SimplePojo) o;
return name.equals(that.name) &&
surname.equals(that.surname);
}
@Override
public int hashCode() {
return Objects.hash(name, surname);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.