- 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 TypeMethodDescriptioncaption()get()default Tstatic <T> Item<T> Creates a newItem, which gets its caption from a resource bundle.static <T> Item<T> Returns anItem, with the caption as item.toString() or an empty string in case of a null valuestatic <T> Item<T> Creates a newItem.
-
Method Details
-
caption
String caption()- Returns:
- the caption
-
get
- Returns:
- the item value
-
getOrThrow
- Returns:
- the item value
- Throws:
NoSuchElementException- if no value is present
-
item
Returns anItem, 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
Itembased on the given value
-
item
Creates a newItem.- Type Parameters:
T- the value type- Parameters:
value- the value, may be nullcaption- the caption- Returns:
- an
Itembased on the given value and caption - Throws:
NullPointerException- if caption is null
-
i18n
Creates a newItem, which gets its caption from a resource bundle. Note that the caption is cached, so that changing theLocaleafter the first timecaption()is called will not change the caption.- Type Parameters:
T- the value type- Parameters:
value- the value, may be nullresourceBundleName- the resource bundle nameresourceBundleKey- the resource bundle key for the item caption- Returns:
- an Item based on the given value and resource bundle
-