Enum Class FlatType

Object
Enum<FlatType>
FlatType
All Implemented Interfaces:
Serializable, Comparable<FlatType>, Constable

public enum FlatType extends Enum<FlatType>
Enum that represents the type of the flats (The assignment assumes there are only 2-Room and 3-Room)
  • Enum Constant Details

    • TWO_ROOM

      public static final FlatType TWO_ROOM
      Represents a 2-Room flat type.
    • THREE_ROOM

      public static final FlatType THREE_ROOM
      Represents a 3-Room flat type.
  • Field Details

    • value

      private String value
  • Constructor Details

    • FlatType

      private FlatType(String value)
      Constructor for FlatType enum.
      Parameters:
      value - The string representation of the FlatType.
  • Method Details

    • values

      public static FlatType[] 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 FlatType 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
    • toString

      public String toString()
      Get the string representation of the FlatType.
      Overrides:
      toString in class Enum<FlatType>
      Returns:
      The string representation of the FlatType.
    • fromString

      public static FlatType fromString(String value)
      Convert a string to the respective FlatType enum.
      Parameters:
      value - The string to convert.
      Returns:
      The FlatType enum that matches the string, or null if no match is found.
    • fromInt

      public static FlatType fromInt(int number)
      Construct base on integer value that can represent a flat type. For example, provide number 2 gives you TWO_ROOM Any unsupported flat type value such as 4 or 5 will result in null