public static Map<String, List<Object>> mergeAttributes(final Map<String, List<Object>> currentAttributes, final Map<String, List<Object>> attributesToMerge) {
        val merger = new MultivaluedAttributeMerger();

        val toModify = currentAttributes.entrySet()
            .stream()
            .map(entry -> Pair.of(entry.getKey(), CollectionUtils.toCollection(entry.getValue(), ArrayList.class)))
            .collect(Collectors.toMap(Pair::getKey, Pair::getValue));

        val toMerge = attributesToMerge.entrySet()
            .stream()
            .map(entry -> Pair.of(entry.getKey(), CollectionUtils.toCollection(entry.getValue(), ArrayList.class)))
            .collect(Collectors.toMap(Pair::getKey, Pair::getValue));

        LOGGER.trace("Merging current attributes [{}] with [{}]", toModify, toMerge);
        val results = merger.mergeAttributes((Map) toModify, (Map) toMerge);
        LOGGER.debug("Merged attributes with the final result as [{}]", results);
        return results;
    }
public static Map < String , List < Object > > mergeAttributes ( final Map < String , List < Object > > currentAttributes , final Map < String , List < Object > > attributesToMerge ) { val merger = new MultivaluedAttributeMerger ( ) ; val toModify = currentAttributes . entrySet ( ) . stream ( ) . map ( entry -> Pair . of ( entry . getKey ( ) , CollectionUtils . toCollection ( entry . getValue ( ) , ArrayList . class ) ) ) . collect ( Collectors . toMap ( Pair :: getKey , Pair :: getValue ) ) ; val toMerge = attributesToMerge . entrySet ( ) . stream ( ) . map ( entry -> Pair . of ( entry . getKey ( ) , CollectionUtils . toCollection ( entry . getValue ( ) , ArrayList . class ) ) ) . collect ( Collectors . toMap ( Pair :: getKey , Pair :: getValue ) ) ; LOGGER . trace ( "Merging current attributes [{}] with [{}]" , toModify , toMerge ) ; val results = merger . mergeAttributes ( ( Map ) toModify , ( Map ) toMerge ) ; LOGGER . debug ( "Merged attributes with the final result as [{}]" , results ) ; return results ; }
Merge attributes map.

@param currentAttributes the current attributes
@param attributesToMerge the attributes to merge
@return the map