All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.capitalone.dashboard.util.ConversionUtils Maven / Gradle / Ivy

There is a newer version: 3.7.33
Show newest version
package com.capitalone.dashboard.util;

import org.apache.commons.collections4.MapUtils;

import java.util.Map;
import java.util.stream.Collectors;

public class ConversionUtils {

    public static final String flattenMap(Map input) {
        return flattenMap(input, "", "");
    }

    public static final String flattenMap(Map input, String prefix, String suffix) {
        if (MapUtils.isEmpty(input)) return "NONE";
        return input.keySet().stream()
                .map(key -> key + "=" + arrayToString(input.get(key)))
                .collect(Collectors.joining(", ", prefix, suffix));
    }

    private static final String arrayToString(String[] input) {
        if (input == null || input.length == 0) return "";
        return String.join("-", input);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy