Record Class LanguageCode

java.lang.Object
java.lang.Record
dev.reuss.tmdb.value.language.LanguageCode
Record Components:
value - the two-letter ISO 639-1 language code
All Implemented Interfaces:
TmdbModel, Serializable

public record LanguageCode(String value) extends Record implements TmdbModel
Represents an ISO 639-1 language code.

TMDB uses ISO 639-1 language codes for localization, for example de, en, pt, fr or ja.

Language codes are usually combined with an ISO 3166-1 alpha-2 region code when sent to TMDB, for example de-DE, en-US or pt-BR.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new ISO 639-1 language code.
  • 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.
    of(String value)
    Creates a language code from a string value.
    Returns the normalized ISO 639-1 language 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

    • LanguageCode

      public LanguageCode(String value)
      Creates a new ISO 639-1 language code.

      The value is normalized to lowercase.

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

    • of

      public static LanguageCode of(String value)
      Creates a language code from a string value.
      Parameters:
      value - the ISO 639-1 language code
      Returns:
      a new language code
      Throws:
      IllegalArgumentException - if value is invalid
    • toString

      public String toString()
      Returns the normalized ISO 639-1 language code.
      Specified by:
      toString in class Record
      Returns:
      the normalized language 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