org.omnaest.utils.structure.map.adapter
Class SortedMapToSortedMapAdapter<KEY,VALUE_FROM,VALUE_TO>

java.lang.Object
  extended by org.omnaest.utils.structure.map.adapter.SortedMapToSortedMapAdapter<KEY,VALUE_FROM,VALUE_TO>
Type Parameters:
KEY -
VALUE_FROM -
VALUE_TO -
All Implemented Interfaces:
Serializable, Map<KEY,VALUE_TO>, SortedMap<KEY,VALUE_TO>

public class SortedMapToSortedMapAdapter<KEY,VALUE_FROM,VALUE_TO>
extends Object
implements SortedMap<KEY,VALUE_TO>, Serializable

The SortedMapToSortedMapAdapter is a decorator and adapter which allows to access a given SortedMap using other types for the values.
Since a SortedMap is sorted by the keys it is not possible to create an adapter for the keys.
The adapter instance is always backed by the original SortedMap and changes on both sides will be traversed to each other side.

Author:
Omnaest
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
SortedMapToSortedMapAdapter(SortedMap<KEY,VALUE_FROM> sourceMap, ElementBidirectionalConverter<VALUE_FROM,VALUE_TO> elementBidirectionalConverterValue)
           
 
Method Summary
 void clear()
           
 Comparator<? super KEY> comparator()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
protected  VALUE_TO convertValueFromToValueTo(VALUE_FROM value_FROM)
           
protected  VALUE_FROM convertValueToToValueFrom(VALUE_TO value_TO)
           
 Set<Map.Entry<KEY,VALUE_TO>> entrySet()
           
 KEY firstKey()
           
 VALUE_TO get(Object key)
           
 SortedMap<KEY,VALUE_TO> headMap(KEY toKey)
           
 boolean isEmpty()
           
 Set<KEY> keySet()
           
 KEY lastKey()
           
 VALUE_TO put(KEY key, VALUE_TO value)
           
 void putAll(Map<? extends KEY,? extends VALUE_TO> map)
           
 VALUE_TO remove(Object key)
           
 int size()
           
 SortedMap<KEY,VALUE_TO> subMap(KEY fromKey, KEY toKey)
           
 SortedMap<KEY,VALUE_TO> tailMap(KEY fromKey)
           
 String toString()
           
 Collection<VALUE_TO> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Constructor Detail

SortedMapToSortedMapAdapter

public SortedMapToSortedMapAdapter(SortedMap<KEY,VALUE_FROM> sourceMap,
                                   ElementBidirectionalConverter<VALUE_FROM,VALUE_TO> elementBidirectionalConverterValue)
Parameters:
sourceMap -
elementBidirectionalConverterValue -
See Also:
SortedMapToSortedMapAdapter
Method Detail

convertValueFromToValueTo

protected VALUE_TO convertValueFromToValueTo(VALUE_FROM value_FROM)

convertValueToToValueFrom

protected VALUE_FROM convertValueToToValueFrom(VALUE_TO value_TO)

get

public VALUE_TO get(Object key)
Specified by:
get in interface Map<KEY,VALUE_TO>

put

public VALUE_TO put(KEY key,
                    VALUE_TO value)
Specified by:
put in interface Map<KEY,VALUE_TO>

remove

public VALUE_TO remove(Object key)
Specified by:
remove in interface Map<KEY,VALUE_TO>

keySet

public Set<KEY> keySet()
Specified by:
keySet in interface Map<KEY,VALUE_TO>
Specified by:
keySet in interface SortedMap<KEY,VALUE_TO>

values

public Collection<VALUE_TO> values()
Specified by:
values in interface Map<KEY,VALUE_TO>
Specified by:
values in interface SortedMap<KEY,VALUE_TO>

size

public int size()
Specified by:
size in interface Map<KEY,VALUE_TO>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Map<KEY,VALUE_TO>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<KEY,VALUE_TO>

containsValue

public boolean containsValue(Object value)
Specified by:
containsValue in interface Map<KEY,VALUE_TO>

putAll

public void putAll(Map<? extends KEY,? extends VALUE_TO> map)
Specified by:
putAll in interface Map<KEY,VALUE_TO>

clear

public void clear()
Specified by:
clear in interface Map<KEY,VALUE_TO>

comparator

public Comparator<? super KEY> comparator()
Specified by:
comparator in interface SortedMap<KEY,VALUE_TO>

subMap

public SortedMap<KEY,VALUE_TO> subMap(KEY fromKey,
                                      KEY toKey)
Specified by:
subMap in interface SortedMap<KEY,VALUE_TO>

headMap

public SortedMap<KEY,VALUE_TO> headMap(KEY toKey)
Specified by:
headMap in interface SortedMap<KEY,VALUE_TO>

tailMap

public SortedMap<KEY,VALUE_TO> tailMap(KEY fromKey)
Specified by:
tailMap in interface SortedMap<KEY,VALUE_TO>

firstKey

public KEY firstKey()
Specified by:
firstKey in interface SortedMap<KEY,VALUE_TO>

lastKey

public KEY lastKey()
Specified by:
lastKey in interface SortedMap<KEY,VALUE_TO>

entrySet

public Set<Map.Entry<KEY,VALUE_TO>> entrySet()
Specified by:
entrySet in interface Map<KEY,VALUE_TO>
Specified by:
entrySet in interface SortedMap<KEY,VALUE_TO>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.