I\'m programming a game in java which is made up of a grid of tiles. I wan\'t to be able to inuitively define the edges of the tiles and how they relate to each other, e.g.
With Java 8 lambdas:
public enum Edge { TOP(() -> Edge.BOTTOM), BOTTOM(() -> Edge.TOP), LEFT(() -> Edge.RIGHT), RIGHT(() -> Edge.LEFT); private Supplier opposite; private Edge(Supplier opposite) { this.opposite = opposite; } public Edge opposite() { return opposite.get(); } }