Record Class Language

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

public record Language(LanguageCode code, Region region) extends Record implements TmdbModel
Represents a TMDB language parameter.

TMDB language parameters are based on ISO 639-1 language codes and are usually combined with ISO 3166-1 alpha-2 region codes.

Examples:

  • de
  • en
  • de-DE
  • en-US
  • pt-BR

The language code controls translated metadata where TMDB supports localization. Person names and character names may not always be localized by TMDB.

See Also:
  • Constructor Details

  • Method Details

    • of

      public static Language of(String value)
      Creates a language parameter from a language code or language tag.

      Accepted formats are ISO 639-1 language codes such as de or en, and language-region tags such as de-DE, en-US or pt-BR.

      Parameters:
      value - the language code or language tag
      Returns:
      a new language parameter
      Throws:
      IllegalArgumentException - if value is null, blank, empty or does not match a supported format
    • of

      public static Language of(LanguageCode code)
      Creates a language parameter without a region.
      Parameters:
      code - the ISO 639-1 language code
      Returns:
      a new language parameter
      Throws:
      NullPointerException - if code is null
    • of

      public static Language of(LanguageCode code, Region region)
      Creates a language parameter with a region.
      Parameters:
      code - the ISO 639-1 language code
      region - the ISO 3166-1 alpha-2 region
      Returns:
      a new language parameter
      Throws:
      NullPointerException - if code is null
    • regionOptional

      public Optional<Region> regionOptional()
      Returns the optional region part of this language parameter.
      Returns:
      the region as an Optional
    • value

      public String value()
      Returns the TMDB language parameter value.

      If no region is present, only the language code is returned, for example de. If a region is present, the value is returned as a language-region tag, for example de-DE.

      Returns:
      the TMDB language parameter value
    • toString

      public String toString()
      Returns the TMDB language parameter value.
      Specified by:
      toString in class Record
      Returns:
      the TMDB language parameter value
    • 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.
    • code

      public LanguageCode code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • region

      public Region region()
      Returns the value of the region record component.
      Returns:
      the value of the region record component