Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
com.expedient.adventofcodejade.common.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable

public enum Direction extends Enum<Direction>
Represents a cardinal direction, and provides methods for use when working with a 2D-array
  • Enum Constant Details

  • Method Details

    • values

      public static Direction[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Direction valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • all

      public static List<Direction> all()
      Convenience method to retrieve a list of all Directions, to allow for easy iteration over them
      Returns:
      list containing all Directions
    • turn

      public abstract Direction turn()
      Returns the direction that is clockwise from the current one
      Returns:
      new direction
    • turnCounterClockwise

      public Direction turnCounterClockwise()
      Returns the direction counterclockwise from the current one
      Returns:
      new direction
    • next

      public abstract Coordinate next(Coordinate location)
      Returns the coordinate that is next from the given location in this direction
      Parameters:
      location - the current location
      Returns:
      the next location, given as a Coordinate