Enum Class Rotation

java.lang.Object
java.lang.Enum<Rotation>
org.refcodes.checkerboard.Rotation
All Implemented Interfaces:
Serializable, Comparable<Rotation>, Constable

public enum Rotation extends Enum<Rotation>
Rotation in terms of "clockwise" or "anti-clockwise". Most useful for getting the next state from a VonNeumannNeighbourhood or MooreNeighbourhood element by calling its Neighbourhood.next(Rotation) method.
  • Enum Constant Details

    • CLOCKWISE

      public static final Rotation CLOCKWISE
      Represents a clockwise rotation.
    • ANTI_CLOCKWISE

      public static final Rotation ANTI_CLOCKWISE
      Represents an anti-clockwise rotation.
  • Method Details

    • values

      public static Rotation[] 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 Rotation 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
    • inverse

      public Rotation inverse()
      Inverts the rotation direction. A CLOCKWISE rotation becomes an ANTI_CLOCKWISE rotation and vice versa.
      Returns:
      The inverted ("the other way round") rotation.
    • next

      public <N extends Neighbourhood<N>> N next(N aNeighbourhood)
      Returns the next neighbourhood relative to the provided neighbourhood. Depending on the Rotation state, either Neighbourhood.clockwiseNext() CLOCKWISE or Neighbourhood.clockwisePrevious() ANTI_CLOCKWISE
      Type Parameters:
      N - The neighbourhood such as the VonNeumannNeighbourhood or the MooreNeighbourhood.
      Parameters:
      aNeighbourhood - The current state for which to retrieve the next neighbourhood.
      Returns:
      The next state relative to the given state.