package com.phlx.anchorcollect_p.db.gen;

import android.database.Cursor;
import android.database.sqlite.SQLiteStatement;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.Property;
import org.greenrobot.greendao.internal.DaoConfig;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.database.DatabaseStatement;

import com.phlx.anchorcollect_p.entity.GenTableColumn;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "GEN_TABLE_COLUMN".
*/
public class GenTableColumnDao extends AbstractDao<GenTableColumn, String> {

    public static final String TABLENAME = "GEN_TABLE_COLUMN";

    /**
     * Properties of entity GenTableColumn.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property ColumnId = new Property(0, String.class, "columnId", true, "COLUMN_ID");
        public final static Property TableId = new Property(1, String.class, "tableId", false, "TABLE_ID");
        public final static Property ColumnName = new Property(2, String.class, "columnName", false, "COLUMN_NAME");
        public final static Property ColumnComment = new Property(3, String.class, "columnComment", false, "COLUMN_COMMENT");
        public final static Property ColumnType = new Property(4, String.class, "columnType", false, "COLUMN_TYPE");
        public final static Property JavaType = new Property(5, String.class, "javaType", false, "JAVA_TYPE");
        public final static Property JavaField = new Property(6, String.class, "javaField", false, "JAVA_FIELD");
        public final static Property IsPk = new Property(7, String.class, "isPk", false, "IS_PK");
        public final static Property IsIncrement = new Property(8, String.class, "isIncrement", false, "IS_INCREMENT");
        public final static Property IsRequired = new Property(9, String.class, "isRequired", false, "IS_REQUIRED");
        public final static Property IsInsert = new Property(10, String.class, "isInsert", false, "IS_INSERT");
        public final static Property IsEdit = new Property(11, String.class, "isEdit", false, "IS_EDIT");
        public final static Property IsList = new Property(12, String.class, "isList", false, "IS_LIST");
        public final static Property IsQuery = new Property(13, String.class, "isQuery", false, "IS_QUERY");
        public final static Property QueryType = new Property(14, String.class, "queryType", false, "QUERY_TYPE");
        public final static Property HtmlType = new Property(15, String.class, "htmlType", false, "HTML_TYPE");
        public final static Property DictType = new Property(16, String.class, "dictType", false, "DICT_TYPE");
        public final static Property Sort = new Property(17, Integer.class, "sort", false, "SORT");
        public final static Property Content = new Property(18, String.class, "content", false, "CONTENT");
        public final static Property ShowName = new Property(19, String.class, "showName", false, "SHOW_NAME");
    }


    public GenTableColumnDao(DaoConfig config) {
        super(config);
    }
    
    public GenTableColumnDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(Database db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"GEN_TABLE_COLUMN\" (" + //
                "\"COLUMN_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: columnId
                "\"TABLE_ID\" TEXT," + // 1: tableId
                "\"COLUMN_NAME\" TEXT," + // 2: columnName
                "\"COLUMN_COMMENT\" TEXT," + // 3: columnComment
                "\"COLUMN_TYPE\" TEXT," + // 4: columnType
                "\"JAVA_TYPE\" TEXT," + // 5: javaType
                "\"JAVA_FIELD\" TEXT," + // 6: javaField
                "\"IS_PK\" TEXT," + // 7: isPk
                "\"IS_INCREMENT\" TEXT," + // 8: isIncrement
                "\"IS_REQUIRED\" TEXT," + // 9: isRequired
                "\"IS_INSERT\" TEXT," + // 10: isInsert
                "\"IS_EDIT\" TEXT," + // 11: isEdit
                "\"IS_LIST\" TEXT," + // 12: isList
                "\"IS_QUERY\" TEXT," + // 13: isQuery
                "\"QUERY_TYPE\" TEXT," + // 14: queryType
                "\"HTML_TYPE\" TEXT," + // 15: htmlType
                "\"DICT_TYPE\" TEXT," + // 16: dictType
                "\"SORT\" INTEGER," + // 17: sort
                "\"CONTENT\" TEXT," + // 18: content
                "\"SHOW_NAME\" TEXT);"); // 19: showName
    }

    /** Drops the underlying database table. */
    public static void dropTable(Database db, boolean ifExists) {
        String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"GEN_TABLE_COLUMN\"";
        db.execSQL(sql);
    }

    @Override
    protected final void bindValues(DatabaseStatement stmt, GenTableColumn entity) {
        stmt.clearBindings();
 
        String columnId = entity.getColumnId();
        if (columnId != null) {
            stmt.bindString(1, columnId);
        }
 
        String tableId = entity.getTableId();
        if (tableId != null) {
            stmt.bindString(2, tableId);
        }
 
        String columnName = entity.getColumnName();
        if (columnName != null) {
            stmt.bindString(3, columnName);
        }
 
        String columnComment = entity.getColumnComment();
        if (columnComment != null) {
            stmt.bindString(4, columnComment);
        }
 
        String columnType = entity.getColumnType();
        if (columnType != null) {
            stmt.bindString(5, columnType);
        }
 
        String javaType = entity.getJavaType();
        if (javaType != null) {
            stmt.bindString(6, javaType);
        }
 
        String javaField = entity.getJavaField();
        if (javaField != null) {
            stmt.bindString(7, javaField);
        }
 
        String isPk = entity.getIsPk();
        if (isPk != null) {
            stmt.bindString(8, isPk);
        }
 
        String isIncrement = entity.getIsIncrement();
        if (isIncrement != null) {
            stmt.bindString(9, isIncrement);
        }
 
        String isRequired = entity.getIsRequired();
        if (isRequired != null) {
            stmt.bindString(10, isRequired);
        }
 
        String isInsert = entity.getIsInsert();
        if (isInsert != null) {
            stmt.bindString(11, isInsert);
        }
 
        String isEdit = entity.getIsEdit();
        if (isEdit != null) {
            stmt.bindString(12, isEdit);
        }
 
        String isList = entity.getIsList();
        if (isList != null) {
            stmt.bindString(13, isList);
        }
 
        String isQuery = entity.getIsQuery();
        if (isQuery != null) {
            stmt.bindString(14, isQuery);
        }
 
        String queryType = entity.getQueryType();
        if (queryType != null) {
            stmt.bindString(15, queryType);
        }
 
        String htmlType = entity.getHtmlType();
        if (htmlType != null) {
            stmt.bindString(16, htmlType);
        }
 
        String dictType = entity.getDictType();
        if (dictType != null) {
            stmt.bindString(17, dictType);
        }
 
        Integer sort = entity.getSort();
        if (sort != null) {
            stmt.bindLong(18, sort);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(19, content);
        }
 
        String showName = entity.getShowName();
        if (showName != null) {
            stmt.bindString(20, showName);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, GenTableColumn entity) {
        stmt.clearBindings();
 
        String columnId = entity.getColumnId();
        if (columnId != null) {
            stmt.bindString(1, columnId);
        }
 
        String tableId = entity.getTableId();
        if (tableId != null) {
            stmt.bindString(2, tableId);
        }
 
        String columnName = entity.getColumnName();
        if (columnName != null) {
            stmt.bindString(3, columnName);
        }
 
        String columnComment = entity.getColumnComment();
        if (columnComment != null) {
            stmt.bindString(4, columnComment);
        }
 
        String columnType = entity.getColumnType();
        if (columnType != null) {
            stmt.bindString(5, columnType);
        }
 
        String javaType = entity.getJavaType();
        if (javaType != null) {
            stmt.bindString(6, javaType);
        }
 
        String javaField = entity.getJavaField();
        if (javaField != null) {
            stmt.bindString(7, javaField);
        }
 
        String isPk = entity.getIsPk();
        if (isPk != null) {
            stmt.bindString(8, isPk);
        }
 
        String isIncrement = entity.getIsIncrement();
        if (isIncrement != null) {
            stmt.bindString(9, isIncrement);
        }
 
        String isRequired = entity.getIsRequired();
        if (isRequired != null) {
            stmt.bindString(10, isRequired);
        }
 
        String isInsert = entity.getIsInsert();
        if (isInsert != null) {
            stmt.bindString(11, isInsert);
        }
 
        String isEdit = entity.getIsEdit();
        if (isEdit != null) {
            stmt.bindString(12, isEdit);
        }
 
        String isList = entity.getIsList();
        if (isList != null) {
            stmt.bindString(13, isList);
        }
 
        String isQuery = entity.getIsQuery();
        if (isQuery != null) {
            stmt.bindString(14, isQuery);
        }
 
        String queryType = entity.getQueryType();
        if (queryType != null) {
            stmt.bindString(15, queryType);
        }
 
        String htmlType = entity.getHtmlType();
        if (htmlType != null) {
            stmt.bindString(16, htmlType);
        }
 
        String dictType = entity.getDictType();
        if (dictType != null) {
            stmt.bindString(17, dictType);
        }
 
        Integer sort = entity.getSort();
        if (sort != null) {
            stmt.bindLong(18, sort);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(19, content);
        }
 
        String showName = entity.getShowName();
        if (showName != null) {
            stmt.bindString(20, showName);
        }
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0);
    }    

    @Override
    public GenTableColumn readEntity(Cursor cursor, int offset) {
        GenTableColumn entity = new GenTableColumn( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // columnId
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // tableId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // columnName
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // columnComment
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // columnType
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // javaType
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // javaField
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // isPk
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // isIncrement
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // isRequired
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // isInsert
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // isEdit
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // isList
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // isQuery
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // queryType
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // htmlType
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // dictType
            cursor.isNull(offset + 17) ? null : cursor.getInt(offset + 17), // sort
            cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // content
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19) // showName
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, GenTableColumn entity, int offset) {
        entity.setColumnId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setTableId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setColumnName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setColumnComment(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setColumnType(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setJavaType(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setJavaField(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setIsPk(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setIsIncrement(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setIsRequired(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setIsInsert(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setIsEdit(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setIsList(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setIsQuery(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setQueryType(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setHtmlType(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setDictType(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setSort(cursor.isNull(offset + 17) ? null : cursor.getInt(offset + 17));
        entity.setContent(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
        entity.setShowName(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
     }
    
    @Override
    protected final String updateKeyAfterInsert(GenTableColumn entity, long rowId) {
        return entity.getColumnId();
    }
    
    @Override
    public String getKey(GenTableColumn entity) {
        if(entity != null) {
            return entity.getColumnId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(GenTableColumn entity) {
        return entity.getColumnId() != null;
    }

    @Override
    protected final boolean isEntityUpdateable() {
        return true;
    }
    
}
