Class Enumeration<K,V>

java.lang.Object
net.sf.basedb.util.Enumeration<K,V>
All Implemented Interfaces:
Serializable

public class Enumeration<K,V> extends Object implements Serializable
Version:
2.0
Author:
Nicklas
See Also:
Last modified
$Date: 2017-04-11 08:43:47 +0200 (ti, 11 apr 2017) $
  • Field Details

  • Constructor Details

    • Enumeration

      public Enumeration()
  • Method Details

    • fromItems

      public static Enumeration<String,String> fromItems(Collection<? extends Nameable> items, String noneOption)
      Create a new enumeration from a list of basic items. The key of the enumeration is the id of each item and the value is the name.
      Parameters:
      items - A collection with items
      noneOption - If not null, this options will be inserted first in the enumeration with an empty string as the key
    • fromItems

      public static Enumeration<String,String> fromItems(Collection<? extends Nameable> items, String noneOption, String noneValue)
      Create a new enumeration from a list of basic items. The key of the enumeration is the id of each item and the value is the name.
      Parameters:
      items - A collection with items
      noneOption - If not null, this options will be inserted first in the enumeration with an empty string as the key
      noneValue - Value for the 'none' option (empty string by default)
      Since:
      3.11
    • from

      public static Enumeration<String,String> from(String... values)
      Create a new enumeration from a list strings. The key and value are the same for each entry. A null value in the array will be translated to key="" and value="none"
      Since:
      3.11
    • isLocked

      public boolean isLocked()
    • lock

      public void lock()
    • size

      public int size()
    • add

      public int add(K key, V value)
    • getKey

      public K getKey(int index)
    • getValue

      public V getValue(int index)
    • getEntry

      public Enumeration.Entry<K,V> getEntry(int index)
    • getEntriesByKey

      public List<Enumeration.Entry<K,V>> getEntriesByKey(K key)
      Get a list with all entries that equals the given key.
      Returns:
      A list which may be empty if no entries are found
      Since:
      3.2.4
    • getEntriesByValue

      public List<Enumeration.Entry<K,V>> getEntriesByValue(V value)
      Get a list with all entries that equals the given value.
      Returns:
      A list which may be empty if no entries are found
      Since:
      3.2.4
    • remove

      public void remove(int index)
    • sortKeys

      public void sortKeys()
      This method will sort the enumration on the keys using Collections.sort(List, Comparator). The comparator will try to use the keys 'compareTo' method if it implements the Comparable interface otherwilse it will treat the key as a String.
    • sortValues

      public void sortValues()
      This method will sort the enumration on the values using Collections.sort(List, Comparator). The comparator will try to use the values 'compareTo' method if it implements the Comparable interface otherwilse it will treat the value as a String.