Class RangeStructure<K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R>
- java.lang.Object
-
- org.faktorips.runtime.internal.tableindex.SearchStructure<R>
-
- org.faktorips.runtime.internal.tableindex.AbstractMapStructure<K,V,R>
-
- org.faktorips.runtime.internal.tableindex.RangeStructure<K,V,R>
-
- All Implemented Interfaces:
MergeAndCopyStructure<RangeStructure<K,V,R>>
public class RangeStructure<K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R> extends AbstractMapStructure<K,V,R> implements MergeAndCopyStructure<RangeStructure<K,V,R>>
ASearchStructurethat maps ranges to nestedSearchStructures. ARangeStructureis configured by aRangeTypeto define how the bounds of the contained ranges should be handled.Ranges are set up by putting one or more key-value pairs into this structure. The key is of a comparable data type (of course, as it defines a range). The value is a nested
SearchStructure. The given key defines one of the bounds of a range, which one depends on theRangeType.Example: In a
RangeType.LOWER_BOUND_EQUALRangeStructure(keys of typeInteger) by callingput(10, value1)andput(25, value2), two ranges are defined: [10..24] and [25..infinity]. Calls toget(Object)with the keys 10, 24 and all in between will yield value1 as a result. Calls toget(Object)with the keys 25 and higher will yield value2 respectively. The keys 9 and lower, however, will return anEmptySearchStructure.- See Also:
RangeType
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RangeStructure<K,V,R>copy()This method copies the object which calls it.static <K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R>
RangeStructure<K,V,R>create(RangeType keyType)Creates an emptyRangeStructure.static <K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R>
RangeStructure<K,V,R>createWith(RangeType keyType, K key, V value)Creates a newRangeStructureand adds the given key-value pair.SearchStructure<R>get(java.lang.Object key)Returns the nestedSearchStructurefor the given key.protected java.util.TreeMap<K,V>getMap()voidmerge(RangeStructure<K,V,R> map)Merging adds the contents of the otherMergable to this object.-
Methods inherited from class org.faktorips.runtime.internal.tableindex.AbstractMapStructure
emptyResult, fillCopy, get, getValidResult, merge, put
-
Methods inherited from class org.faktorips.runtime.internal.tableindex.SearchStructure
getUnique, getUnique
-
-
-
-
Method Detail
-
create
public static <K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R> RangeStructure<K,V,R> create(RangeType keyType)
Creates an emptyRangeStructure.
-
createWith
public static <K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R> RangeStructure<K,V,R> createWith(RangeType keyType, K key, V value)
Creates a newRangeStructureand adds the given key-value pair.
-
get
public SearchStructure<R> get(java.lang.Object key)
Description copied from class:SearchStructureReturns the nestedSearchStructurefor the given key. This method never returnsnull. If no value exists for a given key anEmptySearchStructureis returned as a fall-back.- Specified by:
getin classSearchStructure<R>- Parameters:
key- The key for the requested nestedSearchStructure- Returns:
- The nested
SearchStructureor anEmptySearchStructureif the key does not exist.
-
getMap
protected java.util.TreeMap<K,V> getMap()
- Overrides:
getMapin classAbstractMapStructure<K extends java.lang.Comparable<? super K>,V extends SearchStructure<R> & MergeAndCopyStructure<V>,R>
-
merge
public void merge(RangeStructure<K,V,R> map)
Description copied from interface:MergeAndCopyStructureMerging adds the contents of the otherMergable to this object. This object then contains the combined content. The other object remains unchanged.Merging aSearchStructuredeletes no content, instead equal values are being merged recursively.- Specified by:
mergein interfaceMergeAndCopyStructure<K extends java.lang.Comparable<? super K>>- Parameters:
map- The object that should be merged into this object
-
copy
public RangeStructure<K,V,R> copy()
Description copied from interface:MergeAndCopyStructureThis method copies the object which calls it. The newly created object has the same properties like the object callingMergeAndCopyStructure.copy().- Specified by:
copyin interfaceMergeAndCopyStructure<K extends java.lang.Comparable<? super K>>- Returns:
- T that is a copy of the calling object
-
-