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.GenTable;

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

    public static final String TABLENAME = "GEN_TABLE";

    /**
     * Properties of entity GenTable.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property TableId = new Property(0, String.class, "tableId", true, "TABLE_ID");
        public final static Property TableName = new Property(1, String.class, "tableName", false, "TABLE_NAME");
        public final static Property TableComment = new Property(2, String.class, "tableComment", false, "TABLE_COMMENT");
        public final static Property SubTableName = new Property(3, String.class, "subTableName", false, "SUB_TABLE_NAME");
        public final static Property SubTableFkName = new Property(4, String.class, "subTableFkName", false, "SUB_TABLE_FK_NAME");
        public final static Property ClassName = new Property(5, String.class, "className", false, "CLASS_NAME");
        public final static Property TplCategory = new Property(6, String.class, "tplCategory", false, "TPL_CATEGORY");
        public final static Property PackageName = new Property(7, String.class, "packageName", false, "PACKAGE_NAME");
        public final static Property ModuleName = new Property(8, String.class, "moduleName", false, "MODULE_NAME");
        public final static Property BusinessName = new Property(9, String.class, "businessName", false, "BUSINESS_NAME");
        public final static Property FunctionName = new Property(10, String.class, "functionName", false, "FUNCTION_NAME");
        public final static Property FunctionAuthor = new Property(11, String.class, "functionAuthor", false, "FUNCTION_AUTHOR");
        public final static Property GenType = new Property(12, String.class, "genType", false, "GEN_TYPE");
        public final static Property GenPath = new Property(13, String.class, "genPath", false, "GEN_PATH");
        public final static Property Options = new Property(14, String.class, "options", false, "OPTIONS");
        public final static Property TreeCode = new Property(15, String.class, "treeCode", false, "TREE_CODE");
        public final static Property TreeParentCode = new Property(16, String.class, "treeParentCode", false, "TREE_PARENT_CODE");
        public final static Property TreeName = new Property(17, String.class, "treeName", false, "TREE_NAME");
        public final static Property ParentMenuId = new Property(18, String.class, "parentMenuId", false, "PARENT_MENU_ID");
        public final static Property ParentMenuName = new Property(19, String.class, "parentMenuName", false, "PARENT_MENU_NAME");
        public final static Property RoleId = new Property(20, String.class, "roleId", false, "ROLE_ID");
    }


    public GenTableDao(DaoConfig config) {
        super(config);
    }
    
    public GenTableDao(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\" (" + //
                "\"TABLE_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: tableId
                "\"TABLE_NAME\" TEXT," + // 1: tableName
                "\"TABLE_COMMENT\" TEXT," + // 2: tableComment
                "\"SUB_TABLE_NAME\" TEXT," + // 3: subTableName
                "\"SUB_TABLE_FK_NAME\" TEXT," + // 4: subTableFkName
                "\"CLASS_NAME\" TEXT," + // 5: className
                "\"TPL_CATEGORY\" TEXT," + // 6: tplCategory
                "\"PACKAGE_NAME\" TEXT," + // 7: packageName
                "\"MODULE_NAME\" TEXT," + // 8: moduleName
                "\"BUSINESS_NAME\" TEXT," + // 9: businessName
                "\"FUNCTION_NAME\" TEXT," + // 10: functionName
                "\"FUNCTION_AUTHOR\" TEXT," + // 11: functionAuthor
                "\"GEN_TYPE\" TEXT," + // 12: genType
                "\"GEN_PATH\" TEXT," + // 13: genPath
                "\"OPTIONS\" TEXT," + // 14: options
                "\"TREE_CODE\" TEXT," + // 15: treeCode
                "\"TREE_PARENT_CODE\" TEXT," + // 16: treeParentCode
                "\"TREE_NAME\" TEXT," + // 17: treeName
                "\"PARENT_MENU_ID\" TEXT," + // 18: parentMenuId
                "\"PARENT_MENU_NAME\" TEXT," + // 19: parentMenuName
                "\"ROLE_ID\" TEXT);"); // 20: roleId
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, GenTable entity) {
        stmt.clearBindings();
 
        String tableId = entity.getTableId();
        if (tableId != null) {
            stmt.bindString(1, tableId);
        }
 
        String tableName = entity.getTableName();
        if (tableName != null) {
            stmt.bindString(2, tableName);
        }
 
        String tableComment = entity.getTableComment();
        if (tableComment != null) {
            stmt.bindString(3, tableComment);
        }
 
        String subTableName = entity.getSubTableName();
        if (subTableName != null) {
            stmt.bindString(4, subTableName);
        }
 
        String subTableFkName = entity.getSubTableFkName();
        if (subTableFkName != null) {
            stmt.bindString(5, subTableFkName);
        }
 
        String className = entity.getClassName();
        if (className != null) {
            stmt.bindString(6, className);
        }
 
        String tplCategory = entity.getTplCategory();
        if (tplCategory != null) {
            stmt.bindString(7, tplCategory);
        }
 
        String packageName = entity.getPackageName();
        if (packageName != null) {
            stmt.bindString(8, packageName);
        }
 
        String moduleName = entity.getModuleName();
        if (moduleName != null) {
            stmt.bindString(9, moduleName);
        }
 
        String businessName = entity.getBusinessName();
        if (businessName != null) {
            stmt.bindString(10, businessName);
        }
 
        String functionName = entity.getFunctionName();
        if (functionName != null) {
            stmt.bindString(11, functionName);
        }
 
        String functionAuthor = entity.getFunctionAuthor();
        if (functionAuthor != null) {
            stmt.bindString(12, functionAuthor);
        }
 
        String genType = entity.getGenType();
        if (genType != null) {
            stmt.bindString(13, genType);
        }
 
        String genPath = entity.getGenPath();
        if (genPath != null) {
            stmt.bindString(14, genPath);
        }
 
        String options = entity.getOptions();
        if (options != null) {
            stmt.bindString(15, options);
        }
 
        String treeCode = entity.getTreeCode();
        if (treeCode != null) {
            stmt.bindString(16, treeCode);
        }
 
        String treeParentCode = entity.getTreeParentCode();
        if (treeParentCode != null) {
            stmt.bindString(17, treeParentCode);
        }
 
        String treeName = entity.getTreeName();
        if (treeName != null) {
            stmt.bindString(18, treeName);
        }
 
        String parentMenuId = entity.getParentMenuId();
        if (parentMenuId != null) {
            stmt.bindString(19, parentMenuId);
        }
 
        String parentMenuName = entity.getParentMenuName();
        if (parentMenuName != null) {
            stmt.bindString(20, parentMenuName);
        }
 
        String roleId = entity.getRoleId();
        if (roleId != null) {
            stmt.bindString(21, roleId);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, GenTable entity) {
        stmt.clearBindings();
 
        String tableId = entity.getTableId();
        if (tableId != null) {
            stmt.bindString(1, tableId);
        }
 
        String tableName = entity.getTableName();
        if (tableName != null) {
            stmt.bindString(2, tableName);
        }
 
        String tableComment = entity.getTableComment();
        if (tableComment != null) {
            stmt.bindString(3, tableComment);
        }
 
        String subTableName = entity.getSubTableName();
        if (subTableName != null) {
            stmt.bindString(4, subTableName);
        }
 
        String subTableFkName = entity.getSubTableFkName();
        if (subTableFkName != null) {
            stmt.bindString(5, subTableFkName);
        }
 
        String className = entity.getClassName();
        if (className != null) {
            stmt.bindString(6, className);
        }
 
        String tplCategory = entity.getTplCategory();
        if (tplCategory != null) {
            stmt.bindString(7, tplCategory);
        }
 
        String packageName = entity.getPackageName();
        if (packageName != null) {
            stmt.bindString(8, packageName);
        }
 
        String moduleName = entity.getModuleName();
        if (moduleName != null) {
            stmt.bindString(9, moduleName);
        }
 
        String businessName = entity.getBusinessName();
        if (businessName != null) {
            stmt.bindString(10, businessName);
        }
 
        String functionName = entity.getFunctionName();
        if (functionName != null) {
            stmt.bindString(11, functionName);
        }
 
        String functionAuthor = entity.getFunctionAuthor();
        if (functionAuthor != null) {
            stmt.bindString(12, functionAuthor);
        }
 
        String genType = entity.getGenType();
        if (genType != null) {
            stmt.bindString(13, genType);
        }
 
        String genPath = entity.getGenPath();
        if (genPath != null) {
            stmt.bindString(14, genPath);
        }
 
        String options = entity.getOptions();
        if (options != null) {
            stmt.bindString(15, options);
        }
 
        String treeCode = entity.getTreeCode();
        if (treeCode != null) {
            stmt.bindString(16, treeCode);
        }
 
        String treeParentCode = entity.getTreeParentCode();
        if (treeParentCode != null) {
            stmt.bindString(17, treeParentCode);
        }
 
        String treeName = entity.getTreeName();
        if (treeName != null) {
            stmt.bindString(18, treeName);
        }
 
        String parentMenuId = entity.getParentMenuId();
        if (parentMenuId != null) {
            stmt.bindString(19, parentMenuId);
        }
 
        String parentMenuName = entity.getParentMenuName();
        if (parentMenuName != null) {
            stmt.bindString(20, parentMenuName);
        }
 
        String roleId = entity.getRoleId();
        if (roleId != null) {
            stmt.bindString(21, roleId);
        }
    }

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

    @Override
    public GenTable readEntity(Cursor cursor, int offset) {
        GenTable entity = new GenTable( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // tableId
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // tableName
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // tableComment
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // subTableName
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // subTableFkName
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // className
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // tplCategory
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // packageName
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // moduleName
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // businessName
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // functionName
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // functionAuthor
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // genType
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // genPath
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // options
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // treeCode
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // treeParentCode
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // treeName
            cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // parentMenuId
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // parentMenuName
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // roleId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, GenTable entity, int offset) {
        entity.setTableId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setTableName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setTableComment(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setSubTableName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setSubTableFkName(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setClassName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setTplCategory(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setPackageName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setModuleName(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setBusinessName(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setFunctionName(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setFunctionAuthor(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setGenType(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setGenPath(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setOptions(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setTreeCode(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setTreeParentCode(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setTreeName(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setParentMenuId(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
        entity.setParentMenuName(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
        entity.setRoleId(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
     }
    
    @Override
    protected final String updateKeyAfterInsert(GenTable entity, long rowId) {
        return entity.getTableId();
    }
    
    @Override
    public String getKey(GenTable entity) {
        if(entity != null) {
            return entity.getTableId();
        } else {
            return null;
        }
    }

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

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