Skip to content

Instantly share code, notes, and snippets.

@adam-arold
Created September 11, 2017 16:19
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 adam-arold/0c86e6a2c6bb91f44983c5d9fd342117 to your computer and use it in GitHub Desktop.
Save adam-arold/0c86e6a2c6bb91f44983c5d9fd342117 to your computer and use it in GitHub Desktop.
Kotlin is the new Java - Java POJO
/**
* A plain old Java object with all the boilerplate.
*/
public class HexagonValueObject {
private final int x;
private final int y;
private final int z;
public HexagonValueObject(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
HexagonValueObject hexagon = (HexagonValueObject) o;
return getX() == hexagon.getX() &&
getY() == hexagon.getY() &&
getZ() == hexagon.getZ();
}
@Override
public int hashCode() {
return Objects.hash(getX(), getY(), getZ());
}
@Override
public String toString() {
return "HexagonValueObject{" +
"x=" + x +
", y=" + y +
", z=" + z +
'}';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment