⇒ Index (Frames) |  ⇒ Index (No Frames) |  ⇒ Package |  ⇒ Package Tree |  ⇒ Full Tree 
org.apache.commons.collections.map

Class PredicatedSortedMap

java.lang.Object
|
+--org.apache.commons.collections.map.AbstractMapDecorator
   |
   +--org.apache.commons.collections.map.PredicatedMap
      |
      +--org.apache.commons.collections.map.PredicatedSortedMap

All Implemented Interfaces:
Map, SortedMap


public class PredicatedSortedMap
extends PredicatedMap
implements SortedMap

Decorates another SortedMap to validate that additions match a specified predicate.

If an object cannot be added to the map, an IllegalArgumentException is thrown.

Since:
Commons Collections 3.0
Authors:
Stephen Colebourne
Paul Jack

Constructor Summary

PredicatedSortedMap(SortedMap map, Predicate keyPredicate, Predicate valuePredicate)

Constructor that wraps (not copies).

Method Summary

Comparator

comparator()

static SortedMap

decorate(SortedMap map, Predicate keyPredicate, Predicate valuePredicate)

Factory method to create a predicated (validating) sorted map.

Object

firstKey()

SortedMap

getSortedMap()

Gets the map being decorated.

SortedMap

headMap(Object toKey)

Object

lastKey()

SortedMap

subMap(Object fromKey, Object toKey)

SortedMap

tailMap(Object fromKey)

Constructor Details

PredicatedSortedMap

protected PredicatedSortedMap(SortedMap map, Predicate keyPredicate, Predicate valuePredicate)

Constructor that wraps (not copies).

Parameters:
map - the map to decorate, must not be null
keyPredicate - the predicate to validate the keys, null means no check
valuePredicate - the predicate to validate to values, null means no check
Throws:
- if the map is null

Method Details

comparator

public Comparator comparator()


decorate

public static SortedMap decorate(SortedMap map, Predicate keyPredicate, Predicate valuePredicate)

Factory method to create a predicated (validating) sorted map.

If there are any elements already in the list being decorated, they are validated.

Parameters:
map - the map to decorate, must not be null
keyPredicate - the predicate to validate the keys, null means no check
valuePredicate - the predicate to validate to values, null means no check
Throws:
- if the map is null

firstKey

public Object firstKey()


getSortedMap

protected SortedMap getSortedMap()

Gets the map being decorated.

Returns:
the decorated map

headMap

public SortedMap headMap(Object toKey)

Parameters:
toKey

lastKey

public Object lastKey()


subMap

public SortedMap subMap(Object fromKey, Object toKey)

Parameters:
fromKey
toKey

tailMap

public SortedMap tailMap(Object fromKey)

Parameters:
fromKey