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

org.embulk.input.tsurugidb.common.ToStringMap Maven / Gradle / Ivy

The newest version!
package org.embulk.input.tsurugidb.common;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import com.fasterxml.jackson.annotation.JsonCreator;

// https://github.com/embulk/embulk-input-jdbc/blob/master/embulk-input-jdbc/src/main/java/org/embulk/input/jdbc/ToStringMap.java
@SuppressWarnings("serial")
public class ToStringMap extends HashMap {
    @JsonCreator
    ToStringMap(Map map) {
        super(mapToStringString(map));
    }

    public Properties toProperties() {
        Properties props = new Properties();
        props.putAll(this);
        return props;
    }

    private static Map mapToStringString(final Map mapOfToString) {
        final HashMap result = new HashMap<>();
        for (final Map.Entry entry : mapOfToString.entrySet()) {
            final ToString value = entry.getValue();
            if (value == null) {
                result.put(entry.getKey(), "null");
            } else {
                result.put(entry.getKey(), value.toString());
            }
        }
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy