Class LocalizedValue


  • public class LocalizedValue
    extends java.lang.Object
    A value object for localized attributes. This object captures values for possible different locales the attributes may be set to.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static LocalizedValue EMPTY
      An empty localized value that does not contain any localized values.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      LocalizedValue combine​(LocalizedValue value)
      Sets all values available in the specified LocalizedValue.
      LocalizedValue combine​(java.util.Locale locale, java.lang.String value)
      Sets value for a specific locale.
      boolean equals​(java.lang.Object o)  
      java.lang.String get​(java.util.Locale locale)
      Reads back a value set for the specified locale.
      int hashCode()  
      static LocalizedValue of​(java.util.Locale locale, java.lang.String value)
      Creates instance with a single localized value set for the specified locale.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • EMPTY

        public static final LocalizedValue EMPTY
        An empty localized value that does not contain any localized values.
    • Method Detail

      • of

        public static LocalizedValue of​(java.util.Locale locale,
                                        java.lang.String value)
        Creates instance with a single localized value set for the specified locale.
        Parameters:
        locale - non-null value specifying in what locale the value is.
        value - a locale specific value.
        Returns:
        new instance with the value set.
        Throws:
        java.lang.IllegalArgumentException - if locale is null
      • get

        public java.lang.String get​(java.util.Locale locale)
        Reads back a value set for the specified locale.
        Parameters:
        locale - a locale to read the value for.
        Returns:
        a value last set for the locale or null, if a value for the specified locale has never been set yet.
        See Also:
        combine(Locale, String)
      • combine

        public LocalizedValue combine​(java.util.Locale locale,
                                      java.lang.String value)
        Sets value for a specific locale. Keep in mind this method does not mutate this localized value, therefore to see the change the returned object must be used.
        Parameters:
        locale - a locale to set the value for.
        value - a value for the specified locale.
        Returns:
        a new instance of the LocalizedValue, which contains the value for the specified locale
        Throws:
        java.lang.IllegalArgumentException - if locale is null
      • combine

        public LocalizedValue combine​(LocalizedValue value)
        Sets all values available in the specified LocalizedValue. Keep in mind this method does not mutate this localized value, therefore to see the change the returned object must be used.
        Parameters:
        value - a value to be combined with this LocalizedValue.
        Returns:
        a new instance of the LocalizedValue, which contains all localized values from this and and the specified LocalizedValue
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object