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

io.github.simple4tests.webdriver.utils.Substitutor Maven / Gradle / Ivy

There is a newer version: 3.0.6
Show newest version
package io.github.simple4tests.webdriver.utils;

import org.apache.commons.lang.text.StrSubstitutor;

import java.nio.file.Paths;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class Substitutor {

    public static String replaceSystemProperties(String input) {
        return StrSubstitutor.replaceSystemProperties(input);
    }

    public static List replaceSystemProperties(List inputs) {
        return inputs.stream().map(Substitutor::replaceSystemProperties).collect(Collectors.toList());
    }

    public static Object replaceSystemProperties(Object input) {
        return input instanceof String ? replaceSystemProperties((String) input) : input;
    }

    public static Map.Entry replaceSystemProperties(Map.Entry input) {
        return Map.entry(input.getKey(), replaceSystemProperties(input.getValue()));
    }

    public static Map replaceSystemProperties(Map map) {
        return map.entrySet().stream()
                .map(Substitutor::replaceSystemProperties)
                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    }

    public static String normalizePath(String input) {
        return input.isEmpty() ? input : Paths.get(replaceSystemProperties(input)).toAbsolutePath().toString();
    }

    public static List normalizePath(List inputs) {
        return inputs.stream().map(Substitutor::normalizePath).collect(Collectors.toList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy