Enum Class Direction

java.lang.Object
java.lang.Enum<Direction>
uk.ac.manchester.spinnaker.machine.Direction
All Implemented Interfaces:
Serializable, Comparable<Direction>, Constable

public enum Direction extends Enum<Direction>
A direction from one SpiNNaker chip to another.
Author:
Christian-B
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Direction 0 typically towards a location x + 1, y.
    Direction 2 typically towards a location x, y +1.
    Direction 1 typically towards a location x + 1, y +1.
    Direction 5 typically towards a location x, y -1.
    Direction 4 typically towards a location x -1, y -1.
    Direction 3 typically towards a location x - 1, y.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final int
    The ID of this direction when it is expressed as an int.
    final String
    The string representation, for example used in JSON.
    final int
    The typical change to X when moving in this direction.
    final int
    The typical change to Y when moving in this direction.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Direction
    byId(int id)
    The Direction with this ID when expressed as an int.
    static Direction
    byLabel(String label)
    The Direction with this label
    static Direction
    Returns the enum constant of this class with the specified name.
    static Direction[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • EAST

      public static final Direction EAST
      Direction 0 typically towards a location x + 1, y.
    • NORTHEAST

      public static final Direction NORTHEAST
      Direction 1 typically towards a location x + 1, y +1.
    • NORTH

      public static final Direction NORTH
      Direction 2 typically towards a location x, y +1.
    • WEST

      public static final Direction WEST
      Direction 3 typically towards a location x - 1, y.
    • SOUTHWEST

      public static final Direction SOUTHWEST
      Direction 4 typically towards a location x -1, y -1.
    • SOUTH

      public static final Direction SOUTH
      Direction 5 typically towards a location x, y -1.
  • Field Details

    • id

      public final int id
      The ID of this direction when it is expressed as an int.
    • xChange

      public final int xChange
      The typical change to X when moving in this direction.
    • yChange

      public final int yChange
      The typical change to Y when moving in this direction.
    • label

      public final String label
      The string representation, for example used in JSON.
  • 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
    • byId

      public static Direction byId(int id) throws ArrayIndexOutOfBoundsException
      The Direction with this ID when expressed as an int.
      Parameters:
      id - ID of this Direction
      Returns:
      Direction with this ID
      Throws:
      ArrayIndexOutOfBoundsException - if the ID is not correct
    • byLabel

      public static Direction byLabel(String label)
      The Direction with this label

      The current implementation assumes the labels are lower-case and words are separated by underscore (e.g., north_east).

      Parameters:
      label - Label of a direction
      Returns:
      A valid direction
      Throws:
      IllegalArgumentException - If no direction is found.