org.apache.openejb.jee
Class KeyedCollection<K,V>
java.lang.Object
java.util.AbstractCollection<V>
org.apache.openejb.jee.KeyedCollection<K,V>
- All Implemented Interfaces:
- Iterable<V>, Collection<V>
- Direct Known Subclasses:
- LocalCollection
public class KeyedCollection<K,V>
- extends AbstractCollection<V>
A KeyedCollection is a light weight wrapper around a Map (LinkedHashMap) values set.
When a value is added using the add method of this class a key is obtained for
the value using either the provided KeyExtractor, or if no KeyExtractor was
provided, the value is cast to Keyable and the getKey() method is called.
The underlying Map can be obtainded with the toMap method. Any changes to this
map are directly reflected in this collection. Additions to the map do not
need to implement Keyable, nor do the values need to be keyed using the key
returned from the KeyExtractor.getKey(value) or the key returned from the
Keyable.getKey() Method.
KeyedCollection
public KeyedCollection()
KeyedCollection
public KeyedCollection(KeyExtractor<? extends K,? super V> keyExtractor)
KeyedCollection
public KeyedCollection(Collection<? extends V> c)
KeyedCollection
public KeyedCollection(int initialCapacity)
toMap
public Map<K,V> toMap()
- Get the underlying map used by this collection.
Any changes to this
map are directly reflected in this collection. Additions to the map do not
need to implement Keyable, nor do the values need to be keyed using the key
returned from the KeyExtractor.getKey(value) or the key returned from the
Keyable.getKey() Method.
- Returns:
- the indexed contents of this collection
add
public boolean add(V value)
- Specified by:
add in interface Collection<V>- Overrides:
add in class AbstractCollection<V>
iterator
public Iterator<V> iterator()
- Specified by:
iterator in interface Iterable<V>- Specified by:
iterator in interface Collection<V>- Specified by:
iterator in class AbstractCollection<V>
size
public int size()
- Specified by:
size in interface Collection<V>- Specified by:
size in class AbstractCollection<V>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<V>- Overrides:
isEmpty in class AbstractCollection<V>
clear
public void clear()
- Specified by:
clear in interface Collection<V>- Overrides:
clear in class AbstractCollection<V>
toString
public String toString()
- Overrides:
toString in class AbstractCollection<V>
getKey
protected K getKey(V value)
Copyright © 1999-2011 The Apache Software Foundation. All Rights Reserved.