Package io.goobi.viewer.faces.utils
Class SelectItemBuilder
java.lang.Object
io.goobi.viewer.faces.utils.SelectItemBuilder
Tools to create SelectItem collections to use in jsf components
- Author:
- florian
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> javax.faces.model.SelectItem
createSelectItem
(Function<T, Object> valueSupplier, Function<T, String> labelSupplier, Function<T, String> descriptionSupplier, T value, Predicate<T> disabledPredicate) getAsAlphabeticallySortedMap
(List<T> items, Function<T, String> sortValueSupplier) Sort the given list of items into buckets for each starting letterstatic <T> List<javax.faces.model.SelectItem>
getAsGroupedSelectItems
(Map<String, List<T>> map, Function<T, Object> valueSupplier, Function<T, String> labelSupplier, Function<T, String> descriptionSupplier, Predicate<T> disabledPredicate) Create a List ofselectItems
from the given map, grouped into OptGroups for each map key
-
Method Details
-
getAsAlphabeticallySortedMap
public static <T> SortedMap<String,List<T>> getAsAlphabeticallySortedMap(List<T> items, Function<T, String> sortValueSupplier) Sort the given list of items into buckets for each starting letter- Type Parameters:
T
-- Parameters:
items
- List of items that should be sortedsortValueSupplier
- Function mapping an item to the sting according to which it should be sorted- Returns:
- Map with starting letters of sort values as keys
-
getAsGroupedSelectItems
public static <T> List<javax.faces.model.SelectItem> getAsGroupedSelectItems(Map<String, List<T>> map, Function<T, Object> valueSupplier, Function<T, String> labelSupplier, Function<T, String> descriptionSupplier, Predicate<T> disabledPredicate) Create a List ofselectItems
from the given map, grouped into OptGroups for each map key- Type Parameters:
T
-- Parameters:
map
- Map of items to include in selectItemsvalueSupplier
-labelSupplier
-descriptionSupplier
-disabledPredicate
-- Returns:
- List
-
createSelectItem
public static <T> javax.faces.model.SelectItem createSelectItem(Function<T, Object> valueSupplier, Function<T, String> labelSupplier, Function<T, String> descriptionSupplier, T value, Predicate<T> disabledPredicate) - Type Parameters:
T
-- Parameters:
valueSupplier
-labelSupplier
-descriptionSupplier
-value
-disabledPredicate
-- Returns:
- SelectItem
-