Interface StringBundle

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface StringBundle
String bundle contains locale-specific strings. It can be viewed a specialized variant of ResourceBundle.

Use fromResourceBundle(ResourceBundle) to obtain StringBundle instance from ResourceBundle object.

  • Method Details

    • getString

      String getString(String key)
      Gets a string for the given key from this string bundle.
      Parameters:
      key - the key for the desired string
      Returns:
      the string for the given key
      See Also:
    • format

      default String format(String key, Object... args)
      Gets a formatted message built from the pattern string matching the given key in this string bundle and the given arguments.

      If non-empty list of arguments provided the function calls MessageFormat.format(String, Object...). Otherwise, it returns the result of getString(String) method call.

      Parameters:
      key - the key for the desired pattern
      args - the array of arguments for formatting or an empty array for no formatting
      Returns:
      the formatted message
    • fromResourceBundle

      static StringBundle fromResourceBundle(ResourceBundle bundle)
      Gets StringBundle instance from the given ResourceBundle object.
      Parameters:
      bundle - the resource bundle
      Returns:
      the string bundle