private static Direction getDirection(Direction direction, Rotation rotation) { Direction result; final int value = direction.getValue() + rotation.getValue(); if (value < NORTH.getValue()) { result = WEST; } else if (value > WEST.getValue()) { result = NORTH; } else { result = lookup.get(value); } return result; }
static { for (Direction direction : Direction.values()) { lookup.put(direction.getValue(), direction); } }