Enum Class TrainDirection

java.lang.Object
java.lang.Enum<TrainDirection>
com.cta4j.train.common.model.TrainDirection
All Implemented Interfaces:
Serializable, Comparable<TrainDirection>, Constable

@NullMarked public enum TrainDirection extends Enum<TrainDirection>
Represents the operational direction of a train.

NOTE: This direction is operational in nature and does not necessarily reflect the physical direction of the train at its current location. It loosely translates to a northbound or southbound direction, though this may not be intuitive for all lines.

  • Enum Constant Details

    • NORTHBOUND

      public static final TrainDirection NORTHBOUND
      Indicates a northbound operational direction (CTA direction code 1).
    • SOUTHBOUND

      public static final TrainDirection SOUTHBOUND
      Indicates a southbound operational direction (CTA direction code 5).
  • Method Details

    • values

      public static TrainDirection[] 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 TrainDirection 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
    • getCode

      public int getCode()
      Gets the CTA direction code associated with this direction.
      Returns:
      the CTA direction code
    • fromCode

      public static TrainDirection fromCode(int code)
      Returns the TrainDirection corresponding to the given code.
      Parameters:
      code - the CTA direction code (1 for northbound, 5 for southbound)
      Returns:
      the corresponding TrainDirection
      Throws:
      IllegalArgumentException - if the code does not correspond to any known train direction