Class MTranslatedText

java.lang.Object
com.io7m.montarre.api.MTranslatedText
All Implemented Interfaces:
MTranslatedTextType

public final class MTranslatedText extends Object implements MTranslatedTextType
A text with zero or more alternative translations.
  • Method Details

    • language

      public MLanguageCode language()
      Specified by:
      language in interface MTranslatedTextType
      Returns:
      The base language
    • text

      public String text()
      Specified by:
      text in interface MTranslatedTextType
      Returns:
      The text in the base language
    • translations

      public Map<MLanguageCode, String> translations()
      Specified by:
      translations in interface MTranslatedTextType
      Returns:
      The translations
    • withLanguage

      public final MTranslatedText withLanguage(MLanguageCode value)
      Copy the current immutable object by setting a value for the language attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for language
      Returns:
      A modified copy or the this object
    • withText

      public final MTranslatedText withText(String value)
      Copy the current immutable object by setting a value for the text attribute. An equals check used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for text
      Returns:
      A modified copy or the this object
    • withTranslations

      public final MTranslatedText withTranslations(Map<? extends MLanguageCode, ? extends String> entries)
      Copy the current immutable object by replacing the translations map 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 returning this.
      Parameters:
      entries - The entries to replace the translations map
      Returns:
      A modified copy or this if not changed
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of MTranslatedText that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: language, text, translations.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value MTranslatedText with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • copyOf

      public static MTranslatedText copyOf(MTranslatedTextType instance)
      Creates an immutable copy of a MTranslatedTextType value. 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

      public static MTranslatedText.Builder builder()
      Creates a builder for MTranslatedText.
      MTranslatedText.builder()
         .setLanguage(com.io7m.montarre.api.MLanguageCode) // optional language
         .setText(String) // required text
         .putTranslations|putAllTranslations(com.io7m.montarre.api.MLanguageCode => String) // translations mappings
         .build();
      
      Returns:
      A new MTranslatedText builder