Package com.io7m.montarre.api
Class MTranslatedText
java.lang.Object
com.io7m.montarre.api.MTranslatedText
- All Implemented Interfaces:
MTranslatedTextType
A text with zero or more alternative translations.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic MTranslatedText.Builderbuilder()Creates a builder forMTranslatedText.static MTranslatedTextcopyOf(MTranslatedTextType instance) Creates an immutable copy of aMTranslatedTextTypevalue.booleanThis instance is equal to all instances ofMTranslatedTextthat have equal attribute values.inthashCode()Computes a hash code from attributes:language,text,translations.language()text()toString()Prints the immutable valueMTranslatedTextwith attribute values.final MTranslatedTextwithLanguage(MLanguageCode value) Copy the current immutable object by setting a value for thelanguageattribute.final MTranslatedTextCopy the current immutable object by setting a value for thetextattribute.final MTranslatedTextwithTranslations(Map<? extends MLanguageCode, ? extends String> entries) Copy the current immutable object by replacing thetranslationsmap with the specified map.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.io7m.montarre.api.MTranslatedTextType
all
-
Method Details
-
language
- Specified by:
languagein interfaceMTranslatedTextType- Returns:
- The base language
-
text
- Specified by:
textin interfaceMTranslatedTextType- Returns:
- The text in the base language
-
translations
- Specified by:
translationsin interfaceMTranslatedTextType- Returns:
- The translations
-
withLanguage
Copy the current immutable object by setting a value for thelanguageattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for language- Returns:
- A modified copy of the
thisobject
-
withText
Copy the current immutable object by setting a value for thetextattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for text- Returns:
- A modified copy of the
thisobject
-
withTranslations
public final MTranslatedText withTranslations(Map<? extends MLanguageCode, ? extends String> entries) Copy the current immutable object by replacing thetranslationsmap with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
entries- The entries to be added to the translations map- Returns:
- A modified copy of
thisobject
-
equals
This instance is equal to all instances ofMTranslatedTextthat have equal attribute values. -
hashCode
public int hashCode()Computes a hash code from attributes:language,text,translations. -
toString
Prints the immutable valueMTranslatedTextwith attribute values. -
copyOf
Creates an immutable copy of aMTranslatedTextTypevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance- The instance to copy- Returns:
- A copied immutable MTranslatedText instance
-
builder
Creates a builder forMTranslatedText.MTranslatedText.builder() .setLanguage(com.io7m.montarre.api.MLanguageCode) // optionallanguage.setText(String) // requiredtext.putTranslations|putAllTranslations(com.io7m.montarre.api.MLanguageCode => String) //translationsmappings .build();- Returns:
- A new MTranslatedText builder
-