Interface Item<T>

Type Parameters:
T - the type of the value
All Superinterfaces:
Comparable<Item<T>>, Serializable, Supplier<T>

public interface Item<T> extends Supplier<T>, Comparable<Item<T>>, Serializable
A class encapsulating a constant value and a caption representing the value. Comparing Items is based on their caption. Factory class for Item instances.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
     
    get()
     
    static <T> Item<T>
    item(T value)
    Returns an Item, with the caption as item.toString() or an empty string in case of a null value
    static <T> Item<T>
    item(T value, String caption)
    Creates a new Item.
    static <T> Item<T>
    itemI18n(T value, String resourceBundleName, String resourceBundleKey)
    Creates a new Item, which gets its caption from a resource bundle.

    Methods inherited from interface java.lang.Comparable

    compareTo
  • Method Details

    • caption

      String caption()
      Returns:
      the caption
    • get

      T get()
      Specified by:
      get in interface Supplier<T>
      Returns:
      the item value
    • item

      static <T> Item<T> item(T value)
      Returns an Item, with the caption as item.toString() or an empty string in case of a null value
      Type Parameters:
      T - the value type
      Parameters:
      value - the value, may be null
      Returns:
      an Item based on the given value
    • item

      static <T> Item<T> item(T value, String caption)
      Creates a new Item.
      Type Parameters:
      T - the value type
      Parameters:
      value - the value, may be null
      caption - the caption
      Returns:
      an Item based on the given value and caption
      Throws:
      NullPointerException - if caption is null
    • itemI18n

      static <T> Item<T> itemI18n(T value, String resourceBundleName, String resourceBundleKey)
      Creates a new Item, which gets its caption from a resource bundle. Note that the caption is cached, so that changing the Locale after the first time caption() is called will not change the caption.
      Type Parameters:
      T - the value type
      Parameters:
      value - the value, may be null
      resourceBundleName - the resource bundle name
      resourceBundleKey - the resource bundle key for the item caption
      Returns:
      an Item based on the given value and resource bundle