/*
 * Copyright © 2019 by Data Virtuality GmbH
 */
package org.teiid.metadata;

import org.teiid.query.sql.StreamPositionAware;

import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

/**
 * @author Roman Pedchenko
 * @date 2019.08.05
 */
public class Options {
    private Map<String, String> properties = new TreeMap<>();
    private Map<String, StreamPositionAware> positions = new TreeMap<>();
    private StreamPositionAware argPos = null;
    private StreamPositionAware optPos = null;

    public Set<String> keySet() {
        return properties.keySet();
    }

    public Set<String> posKeySet() {
        return positions.keySet();
    }

    public int size() {
        return properties.size();
    }

    public String getProperty(String key) {
        return properties.get(key);
    }

    public String setProperty(String key, String value) {
        if (value == null) {
            return properties.remove(key);
        }
        return properties.put(key, value);
    }

    public StreamPositionAware getPosition(String key) {
        return positions.get(key);
    }

    public StreamPositionAware setPosition(String key, StreamPositionAware pos) {
        if (pos == null) {
            return positions.remove(key);
        }
        return positions.put(key, pos);
    }

    public StreamPositionAware getArgPos() {
        return argPos;
    }

    public void setArgPos(StreamPositionAware argPos) {
        this.argPos = argPos;
    }

    public StreamPositionAware getOptPos() {
        return optPos;
    }

    public void setOptPos(StreamPositionAware optPos) {
        this.optPos = optPos;
    }

    public Map<String, String> get() {
        return properties;
    }
}
