Created
September 11, 2017 16:19
-
-
Save adam-arold/0c86e6a2c6bb91f44983c5d9fd342117 to your computer and use it in GitHub Desktop.
Kotlin is the new Java - Java POJO
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
/** | |
* 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