package com.casic.common.detector.gd.greendao;

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.casic.common.detector.gd.bean.TaskLocalBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "TASK_LOCAL_BEAN".
*/
public class TaskLocalBeanDao extends AbstractDao<TaskLocalBean, Long> {

    public static final String TABLENAME = "TASK_LOCAL_BEAN";

    /**
     * Properties of entity TaskLocalBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property TaskCode = new Property(1, String.class, "taskCode", false, "TASK_CODE");
        public final static Property Description = new Property(2, String.class, "description", false, "DESCRIPTION");
        public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME");
        public final static Property Status = new Property(4, String.class, "status", false, "STATUS");
        public final static Property CreateUserName = new Property(5, String.class, "createUserName", false, "CREATE_USER_NAME");
        public final static Property StartTime = new Property(6, String.class, "startTime", false, "START_TIME");
        public final static Property EndTime = new Property(7, String.class, "endTime", false, "END_TIME");
        public final static Property IsFreeTask = new Property(8, String.class, "isFreeTask", false, "IS_FREE_TASK");
    }


    public TaskLocalBeanDao(DaoConfig config) {
        super(config);
    }
    
    public TaskLocalBeanDao(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 + "\"TASK_LOCAL_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"TASK_CODE\" TEXT," + // 1: taskCode
                "\"DESCRIPTION\" TEXT," + // 2: description
                "\"CREATE_TIME\" TEXT," + // 3: createTime
                "\"STATUS\" TEXT," + // 4: status
                "\"CREATE_USER_NAME\" TEXT," + // 5: createUserName
                "\"START_TIME\" TEXT," + // 6: startTime
                "\"END_TIME\" TEXT," + // 7: endTime
                "\"IS_FREE_TASK\" TEXT);"); // 8: isFreeTask
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, TaskLocalBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(2, taskCode);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(3, description);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(4, createTime);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(5, status);
        }
 
        String createUserName = entity.getCreateUserName();
        if (createUserName != null) {
            stmt.bindString(6, createUserName);
        }
 
        String startTime = entity.getStartTime();
        if (startTime != null) {
            stmt.bindString(7, startTime);
        }
 
        String endTime = entity.getEndTime();
        if (endTime != null) {
            stmt.bindString(8, endTime);
        }
 
        String isFreeTask = entity.getIsFreeTask();
        if (isFreeTask != null) {
            stmt.bindString(9, isFreeTask);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, TaskLocalBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(2, taskCode);
        }
 
        String description = entity.getDescription();
        if (description != null) {
            stmt.bindString(3, description);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(4, createTime);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(5, status);
        }
 
        String createUserName = entity.getCreateUserName();
        if (createUserName != null) {
            stmt.bindString(6, createUserName);
        }
 
        String startTime = entity.getStartTime();
        if (startTime != null) {
            stmt.bindString(7, startTime);
        }
 
        String endTime = entity.getEndTime();
        if (endTime != null) {
            stmt.bindString(8, endTime);
        }
 
        String isFreeTask = entity.getIsFreeTask();
        if (isFreeTask != null) {
            stmt.bindString(9, isFreeTask);
        }
    }

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

    @Override
    public TaskLocalBean readEntity(Cursor cursor, int offset) {
        TaskLocalBean entity = new TaskLocalBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskCode
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // description
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // status
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // createUserName
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // startTime
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // endTime
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // isFreeTask
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, TaskLocalBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setTaskCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setDescription(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setCreateUserName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setStartTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setEndTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setIsFreeTask(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(TaskLocalBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(TaskLocalBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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