Record Class Region

java.lang.Object
java.lang.Record
dev.reuss.tmdb.value.region.Region
Record Components:
value - the ISO 3166-1 alpha-2 region code
All Implemented Interfaces:
TmdbModel, Serializable

public record Region(String value) extends Record implements TmdbModel
Represents a TMDB region parameter.

TMDB expects regions as ISO 3166-1 alpha-2 country codes, for example DE, US, GB or BR.

The region parameter is used by TMDB as a regional filter or presentation hint, for example for release dates, watch providers and discover/search requests.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Region(String value)
    Creates a new region.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    static Region
    of(String value)
    Creates a region from a string value.
    Returns the normalized ISO 3166-1 alpha-2 region code.
    Returns the value of the value record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Region

      public Region(String value)
      Creates a new region.

      The value is normalized to uppercase.

      Throws:
      IllegalArgumentException - if value is null, blank, empty, not a two-letter code or not known as an ISO 3166-1 alpha-2 country code
  • Method Details

    • of

      public static Region of(String value)
      Creates a region from a string value.
      Parameters:
      value - the ISO 3166-1 alpha-2 region code
      Returns:
      a new region
      Throws:
      IllegalArgumentException - if value is invalid
    • toString

      public String toString()
      Returns the normalized ISO 3166-1 alpha-2 region code.
      Specified by:
      toString in class Record
      Returns:
      the normalized region code
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • value

      public String value()
      Returns the value of the value record component.
      Returns:
      the value of the value record component