package com.eversec.kit.dev;

import com.google.gson.Gson;

import java.util.List;

/**
 * 数据库表.
 * @author: liangxianyou at 2018/10/8 10:58.
 */
public class Table {
    private String name; //表名称
    private String comment; //表备注
    private List<Column> columns; //表的字段列

    /*public Table(Object o) {

    }*/

    public Table(String name, String comment) {
        this.name = name;
        this.comment = comment;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public void setColumns(List<Column> columns) {
        this.columns = columns;
    }

    /**
     * 数据库表的列
     * @author: liangxianyou at 2018/10/8 10:59.
     */
    public static class Column {
        private String name; //列名称
        private String type; //列类型
        private boolean notNull; //不为null
        private String comment; //列说明

        public Column() {
        }

        public Column(String name, String type, boolean notNull,String comment) {
            this.name = name;
            this.type = type;
            this.notNull = notNull;
            this.comment = comment;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getType() {
            return type;
        }

        public void setType(String type) {
            this.type = type;
        }

        public boolean getNotNull() {
            return notNull;
        }

        public void setNotNull(boolean notNull) {
            this.notNull = notNull;
        }

        public String getComment() {
            return comment;
        }

        public void setComment(String comment) {
            this.comment = comment;
        }

        @Override
        public String toString() {
            return new Gson().toJson(this);
        }
    }
}
