package nl.myndocs.database.migrator.database.query.option;

import nl.myndocs.database.migrator.definition.Column;

import java.util.Optional;

/**
 * Created by albert on 20-8-2017.
 */
public class ColumnOptions {
    private final String columnName;
    private final Column.TYPE columnType;
    private final Boolean autoIncrement;
    private final Integer columnSize;
    private final String defaultValue;
    private final Boolean isNotNull;
    private final Boolean isPrimary;

    private ColumnOptions(Builder builder) {
        columnName = builder.getColumnName();
        columnType = builder.getColumnTyoe();
        autoIncrement = builder.getAutoIncrement();
        columnSize = builder.getColumnSize();
        defaultValue = builder.getDefaultValue();
        isNotNull = builder.getNotNull();
        isPrimary = builder.getPrimary();
    }

    public String getColumnName() {
        return columnName;
    }

    public Column.TYPE getColumnType() {
        return columnType;
    }

    public Optional<Boolean> getAutoIncrement() {
        return Optional.ofNullable(autoIncrement);
    }

    public Optional<Integer> getColumnSize() {
        return Optional.ofNullable(columnSize);
    }

    public Optional<String> getDefaultValue() {
        return Optional.ofNullable(defaultValue);
    }

    public Optional<Boolean> getIsNotNull() {
        return Optional.ofNullable(isNotNull);
    }

    public Optional<Boolean> getIsPrimary() {
        return Optional.ofNullable(isPrimary);
    }

    public static class Builder {
        private final String columnName;
        private final Column.TYPE columnTyoe;
        private Boolean autoIncrement;
        private Integer columnSize;
        private String defaultValue;
        private Boolean isNotNull;
        private Boolean isPrimary;

        public Builder(String columnName, Column.TYPE columnTyoe) {
            this.columnName = columnName;
            this.columnTyoe = columnTyoe;
        }

        public String getColumnName() {
            return columnName;
        }

        public Column.TYPE getColumnTyoe() {
            return columnTyoe;
        }

        public Boolean getAutoIncrement() {
            return autoIncrement;
        }

        public Builder setAutoIncrement(Boolean autoIncrement) {
            this.autoIncrement = autoIncrement;

            return this;
        }

        public Integer getColumnSize() {
            return columnSize;
        }

        public Builder setColumnSize(Integer columnSize) {
            this.columnSize = columnSize;

            return this;
        }

        public String getDefaultValue() {
            return defaultValue;
        }

        public Builder setDefaultValue(String defaultValue) {
            this.defaultValue = defaultValue;

            return this;
        }

        public Boolean getNotNull() {
            return isNotNull;
        }

        public Builder setNotNull(Boolean notNull) {
            isNotNull = notNull;

            return this;
        }

        public Boolean getPrimary() {
            return isPrimary;
        }

        public Builder setPrimary(Boolean primary) {
            isPrimary = primary;

            return this;
        }

        public ColumnOptions build() {
            return new ColumnOptions(this);
        }
    }
}

@@ -108,16 +108,65 @@
 .Column;
+%0Aimport nl.myndocs.database.migrator.util.Assert;
 %0A%0Aimport
@@ -662,17 +662,17 @@
 ColumnTy
-o
+p
 e();%0A   
@@ -1676,33 +1676,33 @@
 mn.TYPE columnTy
-o
+p
 e;%0A        priva
@@ -1937,13 +1937,156 @@
 mnTy
-oe) %7B
+pe) %7B%0A            Assert.notNull(columnName, %22columnName must not be null%22);%0A            Assert.notNull(columnType, %22columnType must not be null%22);%0A
 %0A   
@@ -2149,17 +2149,17 @@
 columnTy
-o
+p
 e = colu
@@ -2154,33 +2154,33 @@
 nType = columnTy
-o
+p
 e;%0A        %7D%0A%0A  
@@ -2297,17 +2297,17 @@
 ColumnTy
-o
+p
 e() %7B%0A  
@@ -2331,17 +2331,17 @@
 columnTy
-o
+p
 e;%0A     

Assert null values Fix typo