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

ru.ivi.opensource.flinkclickhousesink.util.ConfigUtil Maven / Gradle / Ivy

Go to download

There is a newer version: 1.4.0
Show newest version
package ru.ivi.opensource.flinkclickhousesink.util;

import com.typesafe.config.Config;
import com.typesafe.config.ConfigValue;

import java.util.*;

public final class ConfigUtil {

    public static final String HOST_DELIMITER = ", ";

    private ConfigUtil(){

    }
    public static Properties toProperties(Config config) {
        Properties properties = new Properties();
        config.entrySet().forEach(e -> properties.put(e.getKey(), unwrapped(config.getValue(e.getKey()))));
        return properties;
    }

    public static Map toMap(Config config) {
        Map map = new HashMap<>();
        config.entrySet().forEach(e -> map.put(e.getKey(), unwrapped(e.getValue())));
        return map;
    }

    private static String unwrapped(ConfigValue configValue) {
        Object object = configValue.unwrapped();
        return object.toString();
    }

    static public String buildStringFromList(List list) {
        return String.join(HOST_DELIMITER, list);
    }

    static public List buildListFromString(String string) {
        return Arrays.asList(string.split(" "));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy