package com.rthoni.intellij.codefromds.dbo.options;

import com.intellij.database.model.DasColumn;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * Created by robin on 11/15/16.
 */
public class ColumnSelection {

    private DasColumn _column;

    private boolean _selected;

    public ColumnSelection(DasColumn column) {
        _column = column;
        _selected = true;
    }

    public HashMap<String, Object> toMap()
    {
        HashMap<String, Object> map = new HashMap<>();

        map.put("column", _column == null ? null : _column.getName());
        map.put("selected", _selected);

        return map;
    }

    public void fromJson(JSONObject json)
    {
        _selected = json.getBoolean("selected");
    }

    public DasColumn getColumn() {
        return _column;
    }

    public void setColumn(DasColumn column) {
        _column = column;
    }

    public boolean isSelected() {
        return _selected;
    }

    public void setSelected(boolean selected) {
        _selected = selected;
    }
}
