Package com.cta4j.train.common.model
Enum Class TrainDirection
- All Implemented Interfaces:
Serializable,Comparable<TrainDirection>,Constable
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionIndicates a northbound operational direction (CTA direction code 1).Indicates a southbound operational direction (CTA direction code 5). -
Method Summary
Modifier and TypeMethodDescriptionstatic TrainDirectionfromCode(int code) Returns theTrainDirectioncorresponding to the given code.intgetCode()Gets the CTA direction code associated with this direction.static TrainDirectionReturns the enum constant of this class with the specified name.static TrainDirection[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
NORTHBOUND
Indicates a northbound operational direction (CTA direction code 1). -
SOUTHBOUND
Indicates a southbound operational direction (CTA direction code 5).
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-
getCode
public int getCode()Gets the CTA direction code associated with this direction.- Returns:
- the CTA direction code
-
fromCode
Returns theTrainDirectioncorresponding 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
-