Class SelectItemBuilder

java.lang.Object
io.goobi.viewer.faces.utils.SelectItemBuilder

public final class SelectItemBuilder extends Object
Tools to create SelectItem collections to use in jsf components
Author:
florian
  • 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 sorted
      sortValueSupplier - 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 of selectItems from the given map, grouped into OptGroups for each map key
      Type Parameters:
      T -
      Parameters:
      map - Map of items to include in selectItems
      valueSupplier -
      labelSupplier -
      descriptionSupplier -
      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