Class DefaultMergeMap<K,T extends AbstractAsConfiguration,R extends AbstractAsConfiguration>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,AsConfigurationHolder<T,R>>
-
- de.hybris.platform.adaptivesearch.strategies.impl.DefaultMergeMap<K,T,R>
-
- All Implemented Interfaces:
MergeMap<K,AsConfigurationHolder<T,R>>,java.io.Serializable,java.lang.Cloneable,java.util.Map<K,AsConfigurationHolder<T,R>>
public class DefaultMergeMap<K,T extends AbstractAsConfiguration,R extends AbstractAsConfiguration> extends java.util.HashMap<K,AsConfigurationHolder<T,R>> implements MergeMap<K,AsConfigurationHolder<T,R>>
Default implementation ofMergeMap.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classDefaultMergeMap.RankComparator
-
Field Summary
Fields Modifier and Type Field Description protected static DefaultMergeMap.RankComparatorRANK_COMPARATOR
-
Constructor Summary
Constructors Constructor Description DefaultMergeMap()DefaultMergeMap(java.util.Comparator<AsConfigurationHolder<T,R>> comparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()booleanequals(java.lang.Object o)intgetHighestRank()Returns the highest rank of the values in the map.intgetLowestRank()Returns the lowest rank of the values in the map.inthashCode()voidmergeAfter(MergeMap<K,AsConfigurationHolder<T,R>> source, MergeFunction<K,AsConfigurationHolder<T,R>> mergeFunction)Merges both maps, all entries from source map are added to this map.AsConfigurationHolder<T,R>mergeAfter(K key, AsConfigurationHolder<T,R> value)Associates the given value with the given key in this map.voidmergeBefore(MergeMap<K,AsConfigurationHolder<T,R>> source, MergeFunction<K,AsConfigurationHolder<T,R>> mergeFunction)Merges both maps, all entries from source map are added to this map.AsConfigurationHolder<T,R>mergeBefore(K key, AsConfigurationHolder<T,R> value)Associates the given value with the given key in this map.java.util.List<AsConfigurationHolder<T,R>>orderedValues()Returns an orderedListof the values contained in this map.AsConfigurationHolder<T,R>put(K key, AsConfigurationHolder<T,R> value)-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
-
-
-
Field Detail
-
RANK_COMPARATOR
protected static final DefaultMergeMap.RankComparator RANK_COMPARATOR
-
-
Constructor Detail
-
DefaultMergeMap
public DefaultMergeMap()
-
DefaultMergeMap
public DefaultMergeMap(java.util.Comparator<AsConfigurationHolder<T,R>> comparator)
-
-
Method Detail
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<K,T extends AbstractAsConfiguration>- Overrides:
clearin classjava.util.HashMap<K,AsConfigurationHolder<T extends AbstractAsConfiguration,R extends AbstractAsConfiguration>>
-
put
public AsConfigurationHolder<T,R> put(K key, AsConfigurationHolder<T,R> value)
- Specified by:
putin interfacejava.util.Map<K,T extends AbstractAsConfiguration>- Overrides:
putin classjava.util.HashMap<K,AsConfigurationHolder<T extends AbstractAsConfiguration,R extends AbstractAsConfiguration>>
-
getHighestRank
public int getHighestRank()
Description copied from interface:MergeMapReturns the highest rank of the values in the map.- Specified by:
getHighestRankin interfaceMergeMap<K,T extends AbstractAsConfiguration>- Returns:
- the highest rank of the values in the map
-
getLowestRank
public int getLowestRank()
Description copied from interface:MergeMapReturns the lowest rank of the values in the map.- Specified by:
getLowestRankin interfaceMergeMap<K,T extends AbstractAsConfiguration>- Returns:
- the lowest rank of the values in the map
-
mergeBefore
public AsConfigurationHolder<T,R> mergeBefore(K key, AsConfigurationHolder<T,R> value)
Description copied from interface:MergeMapAssociates the given value with the given key in this map. The new value is added with an higher rank.- Specified by:
mergeBeforein interfaceMergeMap<K,T extends AbstractAsConfiguration>- Parameters:
key- - the keyvalue- - the value- Returns:
- the previous value, or null if there was no mapping for the key
-
mergeBefore
public void mergeBefore(MergeMap<K,AsConfigurationHolder<T,R>> source, MergeFunction<K,AsConfigurationHolder<T,R>> mergeFunction)
Description copied from interface:MergeMapMerges both maps, all entries from source map are added to this map. The new values are added with an higher rank, the rank hierarchy from the source map is preserved. If the merge function returns null, the mapping is removed.- Specified by:
mergeBeforein interfaceMergeMap<K,T extends AbstractAsConfiguration>- Parameters:
source- - the source mapmergeFunction- - the merge function
-
mergeAfter
public AsConfigurationHolder<T,R> mergeAfter(K key, AsConfigurationHolder<T,R> value)
Description copied from interface:MergeMapAssociates the given value with the given key in this map. The new value is added with a lower rank.- Specified by:
mergeAfterin interfaceMergeMap<K,T extends AbstractAsConfiguration>- Parameters:
key- - the keyvalue- - the value- Returns:
- the previous value, or null if there was no mapping for the key
-
mergeAfter
public void mergeAfter(MergeMap<K,AsConfigurationHolder<T,R>> source, MergeFunction<K,AsConfigurationHolder<T,R>> mergeFunction)
Description copied from interface:MergeMapMerges both maps, all entries from source map are added to this map. The new values are added with a lower rank, the rank hierarchy from the source map is preserved. If the merge function returns null, the mapping is removed.- Specified by:
mergeAfterin interfaceMergeMap<K,T extends AbstractAsConfiguration>- Parameters:
source- - the source mapmergeFunction- - the merge function
-
orderedValues
public java.util.List<AsConfigurationHolder<T,R>> orderedValues()
Description copied from interface:MergeMapReturns an orderedListof the values contained in this map.- Specified by:
orderedValuesin interfaceMergeMap<K,T extends AbstractAsConfiguration>- Returns:
- an ordered
Listof the values contained in this map
-
equals
public boolean equals(java.lang.Object o)
- Specified by:
equalsin interfacejava.util.Map<K,T extends AbstractAsConfiguration>- Overrides:
equalsin classjava.util.AbstractMap<K,AsConfigurationHolder<T extends AbstractAsConfiguration,R extends AbstractAsConfiguration>>
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map<K,T extends AbstractAsConfiguration>- Overrides:
hashCodein classjava.util.AbstractMap<K,AsConfigurationHolder<T extends AbstractAsConfiguration,R extends AbstractAsConfiguration>>
-
-