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

apoc.diff.SourceDestConfig Maven / Gradle / Ivy

There is a newer version: 4.4.0.35
Show newest version
package apoc.diff;

import java.util.Collections;
import java.util.Map;

public class SourceDestConfig {
    public enum SourceDestConfigType { URL, DATABASE }

    static class TargetConfig {
        private final SourceDestConfigType type;
        private final String value;

        public TargetConfig(SourceDestConfigType type, String value) {
            this.type = type;
            this.value = value;
        }

        public SourceDestConfigType getType() {
            return type;
        }

        public String getValue() {
            return value;
        }
    }

    private final Map params;
    private final TargetConfig target;

    public SourceDestConfig(SourceDestConfigType type, String value, Map params) {
        this.target = new TargetConfig(type, value);
        this.params = params;
    }

    public TargetConfig getTarget() {
        return target;
    }

    public Map getParams() {
        return params;
    }

    public static SourceDestConfig fromMap(Map map) {
        map = map == null ? Collections.emptyMap() : map;
        if (map.isEmpty()) {
            return null;
        } else {
            Map target = (Map) map.getOrDefault("target", Collections.emptyMap());
            SourceDestConfigType type = SourceDestConfigType
                    .valueOf((String) target.getOrDefault("type", SourceDestConfigType.URL.toString()));
            return new SourceDestConfig(type,
                    (String) target.get("value"),
                    (Map) map.getOrDefault("params", Collections.emptyMap()));
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy