Enum Class MetroCode

java.lang.Object
java.lang.Enum<MetroCode>
com.eqixiac.equinix.core.enums.MetroCode
All Implemented Interfaces:
APIParam, Serializable, Comparable<MetroCode>, Constable

public enum MetroCode extends Enum<MetroCode> implements APIParam
Well-known Equinix metro codes.

UNKNOWN is a forward-compatibility sentinel: a metro the API returns that this enum does not yet list deserializes to UNKNOWN rather than failing the response (see MetroCodeDeserializer). The authoritative, always-current set of metros is the Metros API (fabric.metros()); this enum is a convenience for the well-known ones.

Author:
ianjones
  • Enum Constant Details

  • Method Details

    • values

      public static MetroCode[] 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 MetroCode 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
    • lookup

      public static Optional<MetroCode> lookup(String code)
      Resolves a wire metro code (e.g. "SV") to its enum constant, if this enum lists it. The lookup is case-insensitive and trims surrounding whitespace. The UNKNOWN sentinel is never returned as a match - a code that does not name a known metro yields Optional.empty().
      Parameters:
      code - the metro code as returned by the API
      Returns:
      the matching MetroCode, or empty if code is null/blank or not a known metro
    • fromCode

      public static MetroCode fromCode(String code)
      Resolves a wire metro code to its enum constant, falling back to UNKNOWN for a code this enum does not list (so callers always get a non-null value). Use lookup(String) when you need to distinguish "unknown" from a real metro.
      Parameters:
      code - the metro code as returned by the API
      Returns:
      the matching MetroCode, or UNKNOWN