Package dev.reuss.tmdb.value.language
Record Class Language
java.lang.Object
java.lang.Record
dev.reuss.tmdb.value.language.Language
- Record Components:
code- the ISO 639-1 language coderegion- the optional ISO 3166-1 alpha-2 region
- All Implemented Interfaces:
TmdbModel,Serializable
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:
deende-DEen-USpt-BR
The language code controls translated metadata where TMDB supports localization. Person names and character names may not always be localized by TMDB.
-
Constructor Summary
ConstructorsConstructorDescriptionLanguage(LanguageCode code, Region region) Creates a new language parameter. -
Method Summary
Modifier and TypeMethodDescriptioncode()Returns the value of thecoderecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Languageof(LanguageCode code) Creates a language parameter without a region.static Languageof(LanguageCode code, Region region) Creates a language parameter with a region.static LanguageCreates a language parameter from a language code or language tag.region()Returns the value of theregionrecord component.Returns the optional region part of this language parameter.toString()Returns the TMDB language parameter value.value()Returns the TMDB language parameter value.
-
Constructor Details
-
Language
Creates a new language parameter.- Throws:
NullPointerException- ifcodeisnull
-
-
Method Details
-
of
Creates a language parameter from a language code or language tag.Accepted formats are ISO 639-1 language codes such as
deoren, and language-region tags such asde-DE,en-USorpt-BR.- Parameters:
value- the language code or language tag- Returns:
- a new language parameter
- Throws:
IllegalArgumentException- ifvalueisnull, blank, empty or does not match a supported format
-
of
Creates a language parameter without a region.- Parameters:
code- the ISO 639-1 language code- Returns:
- a new language parameter
- Throws:
NullPointerException- ifcodeisnull
-
of
Creates a language parameter with a region.- Parameters:
code- the ISO 639-1 language coderegion- the ISO 3166-1 alpha-2 region- Returns:
- a new language parameter
- Throws:
NullPointerException- ifcodeisnull
-
regionOptional
Returns the optional region part of this language parameter.- Returns:
- the region as an
Optional
-
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 examplede-DE.- Returns:
- the TMDB language parameter value
-
toString
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. -
equals
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 withObjects::equals(Object,Object). -
code
Returns the value of thecoderecord component.- Returns:
- the value of the
coderecord component
-
region
Returns the value of theregionrecord component.- Returns:
- the value of the
regionrecord component
-