Class DefaultCollectionHelper
java.lang.Object
de.hybris.platform.cms2.common.service.impl.DefaultCollectionHelper
- All Implemented Interfaces:
CollectionHelper
Default implementation of
CollectionHelper.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconcatCollections(Collection<Object> first, Collection<Object> second) Concatenates two collections.Resolver for twoMapvalues that have the same key.protected booleanisCollection(Object obj) Method to test whether theObjectis aCollectionor not.protected booleanMerges the list of maps.Merges the list of maps.mergeMaps(Map<String, Object> firstMap, Map<String, Object> secondMap, BinaryOperator<Object> mergeFunction) Merges two maps.
-
Constructor Details
-
DefaultCollectionHelper
public DefaultCollectionHelper()
-
-
Method Details
-
mergeMaps
public Map<String,Object> mergeMaps(Map<String, Object> firstMap, Map<String, Object> secondMap, BinaryOperator<Object> mergeFunction) Description copied from interface:CollectionHelperMerges two maps. If a value already exists for a given key in a resulting map
then the mergeFunction is used to resolve the issue.- Specified by:
mergeMapsin interfaceCollectionHelper- Parameters:
firstMap- theMapto mergesecondMap- theMapto mergemergeFunction- the function used to resolve conflict for the same key- Returns:
- the
Map
-
mergeMaps
Merges the list of maps.
The default implementation usesCollectionHelper.defaultDeepMergeFunction()
if a value already exists for a given key in a resulting map.- Specified by:
mergeMapsin interfaceCollectionHelper- Parameters:
maps- theListofMap.- Returns:
- the
Map
-
mergeMaps
public Map<String,Object> mergeMaps(List<Map<String, Object>> maps, BinaryOperator<Object> mergeFunction) Description copied from interface:CollectionHelperMerges the list of maps. If a value already exists for a given key in a resulting map
then the mergeFunction is used to resolve the issue.- Specified by:
mergeMapsin interfaceCollectionHelper- Parameters:
maps- theListofMap.mergeFunction- the function used to resolve conflict for the same key- Returns:
- the
Map
-
defaultDeepMergeFunction
Resolver for twoMapvalues that have the same key. The default implementation has the following logic: - If two values are collections they will be concatenated - If two values are maps they will be merged usingCollectionHelper.mergeMaps(List, BinaryOperator)- Otherwise the value from the secondMapis returned- Specified by:
defaultDeepMergeFunctionin interfaceCollectionHelper- Returns:
- the
BinaryOperatorto merge two values with the same key.
-
isCollection
Method to test whether theObjectis aCollectionor not.- Parameters:
obj- theObjectto test- Returns:
- true if the
Objectis aCollection, false otherwise.
-
isMap
-
concatCollections
Concatenates two collections.- Parameters:
first- the firstCollectionsecond- the secondCollection- Returns:
- the concatenation of two collections
-