Interface Item<T>

Type Parameters:
T - the type of the value

public interface Item<T>
A class encapsulating a constant value and a caption representing the value. Items equality is based on their values only. Factory for Item instances.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
     
    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.
     
  • Method Details

    • caption

      String caption()
      Returns:
      the caption
    • value

      T value()
      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