diff options
| author | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
|---|---|---|
| committer | Ben Culkin <scorpress@gmail.com> | 2020-04-13 18:40:41 -0400 |
| commit | d4ca769e542b2489b1e23cfcbdc3a0b7275b87cd (patch) | |
| tree | 1653a7399f97fb0c63ce62e3f60fd830d5c37f70 /base/src/main/java/bjc/utils/misc/Direction.java | |
| parent | 2ac2e31a56ae59ee582e43a90c3495f86dd9ee7a (diff) | |
Cleanup pass
Cleanup pass to uniformize things
Diffstat (limited to 'base/src/main/java/bjc/utils/misc/Direction.java')
| -rw-r--r-- | base/src/main/java/bjc/utils/misc/Direction.java | 154 |
1 files changed, 73 insertions, 81 deletions
diff --git a/base/src/main/java/bjc/utils/misc/Direction.java b/base/src/main/java/bjc/utils/misc/Direction.java index b8a982e..6455d8d 100644 --- a/base/src/main/java/bjc/utils/misc/Direction.java +++ b/base/src/main/java/bjc/utils/misc/Direction.java @@ -11,10 +11,10 @@ import bjc.funcdata.IList; /** * A set of cardinal directions - * - * The particular axis assigned to the coordinates are based off of x being - * the bottom left axis on a conventional 3D plot - * + * + * The particular axis assigned to the coordinates are based off of x being the + * bottom left axis on a conventional 3D plot + * * @author ben * */ @@ -51,7 +51,7 @@ public enum Direction { /** * Get a list of all the cardinal directions - * + * * @return A list of all the cardinal directions */ public static IList<Direction> cardinals() { @@ -59,9 +59,8 @@ public enum Direction { } /** - * Perform the specified action once with each of the cardinal - * directions - * + * Perform the specified action once with each of the cardinal directions + * * @param act * The action to perform for each cardinal direction */ @@ -71,15 +70,14 @@ public enum Direction { /** * Perform a specified action for a random number of cardinals. - * + * * @param nCardinals - * The number of cardinal directions to act on. Must be - * greater than 0 and less then 5 + * The number of cardinal directions to act on. Must be + * greater than 0 and less then 5 * @param act - * The action to perform for each of the cardinals + * The action to perform for each of the cardinals */ - public static void forRandomCardinals(int nCardinals, - Consumer<Direction> act) { + public static void forRandomCardinals(int nCardinals, Consumer<Direction> act) { if (nCardinals <= 0 || nCardinals > 4) { throw new IllegalArgumentException( "Tried to do things with incorrect number of cardinal directions. Tried with " @@ -99,9 +97,9 @@ public enum Direction { /** * Create a value of the enumeration from a string - * + * * @param value - * The string to turn into a value + * The string to turn into a value * @return The direction corresponding to the given value */ public static Direction properValueOf(String value) { @@ -110,103 +108,97 @@ public enum Direction { /** * Test if this direction is a cardinal direction - * + * * @return If the direction is cardinal or not */ public boolean isCardinal() { switch (this) { - case EAST: - case NORTH: - case SOUTH: - case WEST: - return true; - case DOWN: - case UP: - return false; - default: - throw new InvalidDirectionException( - "WAT. Somehow ended up with an invalid direction " - + this); + case EAST: + case NORTH: + case SOUTH: + case WEST: + return true; + case DOWN: + case UP: + return false; + default: + throw new InvalidDirectionException( + "WAT. Somehow ended up with an invalid direction " + this); } } /** * Get the direction that opposes the current one - * - * @return The direction that is in the opposite direction of the - * current one + * + * @return The direction that is in the opposite direction of the current one */ public Direction opposing() { switch (this) { - case NORTH: - return SOUTH; - case EAST: - return WEST; - case SOUTH: - return NORTH; - case WEST: - return WEST; - case UP: - return DOWN; - case DOWN: - return UP; - default: - throw new IllegalStateException( - "Enumeration got into a invalid state. WAT"); + case NORTH: + return SOUTH; + case EAST: + return WEST; + case SOUTH: + return NORTH; + case WEST: + return WEST; + case UP: + return DOWN; + case DOWN: + return UP; + default: + throw new IllegalStateException("Enumeration got into a invalid state. WAT"); } } /** * Get the direction that is clockwise on the compass from this one. - * + * * Only works on cardinals. - * + * * @return The cardinal clockwise from this one */ public Direction rotateClockwise() { switch (this) { - case NORTH: - return EAST; - case EAST: - return SOUTH; - case SOUTH: - return WEST; - case WEST: - return NORTH; - case UP: - case DOWN: - default: - throw new InvalidDirectionException( - "Can't rotate non-cardinal direction clockwise: " - + this); + case NORTH: + return EAST; + case EAST: + return SOUTH; + case SOUTH: + return WEST; + case WEST: + return NORTH; + case UP: + case DOWN: + default: + throw new InvalidDirectionException( + "Can't rotate non-cardinal direction clockwise: " + this); } } /** - * Get the direction that is counter-clockwise on the compass from this - * one. - * + * Get the direction that is counter-clockwise on the compass from this one. + * * Only works on cardinals. - * + * * @return The cardinal counter-clockwise from this one */ public Direction rotateCounterClockwise() { switch (this) { - case NORTH: - return WEST; - case EAST: - return NORTH; - case SOUTH: - return EAST; - case WEST: - return SOUTH; - case UP: - case DOWN: - default: - throw new InvalidDirectionException( - "Can't rotate non-cardinal direction counterclockwise: " - + this); + case NORTH: + return WEST; + case EAST: + return NORTH; + case SOUTH: + return EAST; + case WEST: + return SOUTH; + case UP: + case DOWN: + default: + throw new InvalidDirectionException( + "Can't rotate non-cardinal direction counterclockwise: " + this); } } |
