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

com.ats.tools.report.actions.HtmlReportActionKeyValueTemplate Maven / Gradle / Ivy

The newest version!
package com.ats.tools.report.actions;

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

public class HtmlReportActionKeyValueTemplate {
    private static final String DATA_KEY_VALUE_MAIN_TEMPLATE = "
${dataProperties}
"; private static final String DATA_KEY_VALUE_TEMPLATE = "
\n" + "
\n" + " ${dataKey}\n" + "
\n" + "
\n" + " ${dataValue}\n" + "
\n" + "
"; private static final String DATA_KEY_VALUE_INLINE_TEMPLATE = "${dataKey}${dataValue}"; public static String buildEntireKeyValueString(Map keyValues, boolean isColumnDirection) { String items = keyValues.entrySet().stream().map((Map.Entry values) -> buildKeyValueString(values, true)).collect(Collectors.joining()); if (isColumnDirection) { return DATA_KEY_VALUE_MAIN_TEMPLATE.replace("${dataProperties}", items).replace("${direction}", "column"); } else { return DATA_KEY_VALUE_MAIN_TEMPLATE.replace("${dataProperties}", items).replace("${direction}", "row"); } } public static String buildEntireKeyValueInLineString(Map keyValues) { return keyValues.entrySet().stream().map((Map.Entry stringStringMap) -> buildKeyValueString(stringStringMap, true)).collect(Collectors.joining()); } private static String buildKeyValueString(Map.Entry values, boolean isInLine) { return isInLine ? processString(DATA_KEY_VALUE_INLINE_TEMPLATE, values) : processString(DATA_KEY_VALUE_TEMPLATE, values); } private static String processString(String template, Map.Entry values) { return template.replace("${dataKey}", values.getKey() + ":").replace("${dataValue}", values.getValue().equals("NO_DATA_AVAILABLE") ? "Ø" : values.getValue()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy