Class MetroId

java.lang.Object
com.eqixiac.equinix.core.model.MetroId

public final class MetroId extends Object
A forward-compatible identifier for an Equinix metro: a normalized metro code string that can name any metro, including ones added after this SDK was built and therefore absent from the MetroCode enum. Use it where a metro must be referenced by code without being constrained to the well-known set - e.g. keys in MetroRegistry, or provisioning against a brand-new metro.

The code is normalized to upper case with surrounding whitespace trimmed. Two MetroIds are equal when their normalized codes match. asMetroCode() bridges back to the enum when the code is one of the well-known metros.

Author:
ianjones
  • Method Details

    • of

      public static MetroId of(String code)
      Creates a MetroId from a metro code string (e.g. "SV", "da").
      Parameters:
      code - the metro code; normalized to upper case and trimmed
      Returns:
      the metro id
      Throws:
      NullPointerException - if code is null
      IllegalArgumentException - if code is blank
    • of

      public static MetroId of(MetroCode metroCode)
      Creates a MetroId from a well-known MetroCode.
      Parameters:
      metroCode - the metro code enum constant
      Returns:
      the metro id
      Throws:
      NullPointerException - if metroCode is null
    • code

      public String code()
      Returns:
      the normalized metro code string (e.g. "SV")
    • asMetroCode

      public Optional<MetroCode> asMetroCode()
      Returns:
      the matching MetroCode enum constant, or empty if this code is not one of the well-known metros listed by MetroCode
    • isKnown

      public boolean isKnown()
      Returns:
      true if this code names a metro present in the MetroCode enum
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object