net.sf.basedb.util
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:
- Serialized Form
- Last modified
- $Date: 2013-11-19 11:28:33 +0100 (Tue, 19 Nov 2013) $
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
entries
private final List<Enumeration.Entry<K,V>> entries
locked
private boolean locked
Enumeration
public Enumeration()
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 itemsnoneOption
- If not null, this options will be inserted first in the
enumeration with an empty string as the key
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.