public class Enumeration<K,V>
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Enumeration.Entry<K,V> |
Modifier and Type | Field and Description |
---|---|
private java.util.List<Enumeration.Entry<K,V>> |
entries |
private boolean |
locked |
private static long |
serialVersionUID |
Constructor and Description |
---|
Enumeration() |
Modifier and Type | Method and Description |
---|---|
int |
add(K key,
V value) |
static Enumeration<java.lang.String,java.lang.String> |
from(java.lang.String... values)
Create a new enumeration from a list strings.
|
static Enumeration<java.lang.String,java.lang.String> |
fromItems(java.util.Collection<? extends Nameable> items,
java.lang.String noneOption)
Create a new enumeration from a list of basic items.
|
static Enumeration<java.lang.String,java.lang.String> |
fromItems(java.util.Collection<? extends Nameable> items,
java.lang.String noneOption,
java.lang.String noneValue)
Create a new enumeration from a list of basic items.
|
java.util.List<Enumeration.Entry<K,V>> |
getEntriesByKey(K key)
Get a list with all entries that equals the given key.
|
java.util.List<Enumeration.Entry<K,V>> |
getEntriesByValue(V value)
Get a list with all entries that equals the given value.
|
Enumeration.Entry<K,V> |
getEntry(int index) |
K |
getKey(int index) |
V |
getValue(int index) |
boolean |
isLocked() |
void |
lock() |
void |
remove(int index) |
int |
size() |
void |
sortKeys()
This method will sort the enumration on the keys using
Collections.sort(List, Comparator) . |
void |
sortValues()
This method will sort the enumration on the values using
Collections.sort(List, Comparator) . |
private static final long serialVersionUID
private final java.util.List<Enumeration.Entry<K,V>> entries
private boolean locked
public static Enumeration<java.lang.String,java.lang.String> fromItems(java.util.Collection<? extends Nameable> items, java.lang.String noneOption)
items
- A collection with itemsnoneOption
- If not null, this options will be inserted first in the
enumeration with an empty string as the keypublic static Enumeration<java.lang.String,java.lang.String> fromItems(java.util.Collection<? extends Nameable> items, java.lang.String noneOption, java.lang.String noneValue)
items
- A collection with itemsnoneOption
- If not null, this options will be inserted first in the
enumeration with an empty string as the keynoneValue
- Value for the 'none' option (empty string by default)public static Enumeration<java.lang.String,java.lang.String> from(java.lang.String... values)
public boolean isLocked()
public void lock()
public int size()
public K getKey(int index)
public V getValue(int index)
public Enumeration.Entry<K,V> getEntry(int index)
public java.util.List<Enumeration.Entry<K,V>> getEntriesByKey(K key)
public java.util.List<Enumeration.Entry<K,V>> getEntriesByValue(V value)
public void remove(int index)
public void sortKeys()
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.public void sortValues()
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.