Enum Direction

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

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

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

    Fields 
    Modifier and Type Field Description
    int id
    The ID of this direction when it is expressed as an int.
    String label
    The string representation, for example used in JSON.
    int xChange
    The typical change to X when moving in this direction.
    int yChange
    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 valueOf​(String name)
    Returns the enum constant of this type with the specified name.
    static Direction[] values()
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Enum

    clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf

    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 type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static Direction valueOf​(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type 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.