package com.casic.detector.greendao;

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

import com.casic.detector.bean.TaskBean;

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

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

    public static final String TABLENAME = "TASK_BEAN";

    /**
     * Properties of entity TaskBean.<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 Scanner = new Property(1, String.class, "scanner", false, "SCANNER");
        public final static Property Desc = new Property(2, String.class, "desc", false, "DESC");
        public final static Property TaskId = new Property(3, String.class, "taskId", false, "TASK_ID");
        public final static Property TaskCode = new Property(4, String.class, "taskCode", false, "TASK_CODE");
        public final static Property MarkerId = new Property(5, String.class, "markerId", false, "MARKER_ID");
        public final static Property MarkerRealId = new Property(6, String.class, "markerRealId", false, "MARKER_REAL_ID");
        public final static Property Lng = new Property(7, String.class, "lng", false, "LNG");
        public final static Property Lat = new Property(8, String.class, "lat", false, "LAT");
        public final static Property State = new Property(9, String.class, "state", false, "STATE");
    }


    public TaskBeanDao(DaoConfig config) {
        super(config);
    }
    
    public TaskBeanDao(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_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"SCANNER\" TEXT," + // 1: scanner
                "\"DESC\" TEXT," + // 2: desc
                "\"TASK_ID\" TEXT," + // 3: taskId
                "\"TASK_CODE\" TEXT," + // 4: taskCode
                "\"MARKER_ID\" TEXT," + // 5: markerId
                "\"MARKER_REAL_ID\" TEXT," + // 6: markerRealId
                "\"LNG\" TEXT," + // 7: lng
                "\"LAT\" TEXT," + // 8: lat
                "\"STATE\" TEXT);"); // 9: state
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, TaskBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String scanner = entity.getScanner();
        if (scanner != null) {
            stmt.bindString(2, scanner);
        }
 
        String desc = entity.getDesc();
        if (desc != null) {
            stmt.bindString(3, desc);
        }
 
        String taskId = entity.getTaskId();
        if (taskId != null) {
            stmt.bindString(4, taskId);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(5, taskCode);
        }
 
        String markerId = entity.getMarkerId();
        if (markerId != null) {
            stmt.bindString(6, markerId);
        }
 
        String markerRealId = entity.getMarkerRealId();
        if (markerRealId != null) {
            stmt.bindString(7, markerRealId);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(8, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(9, lat);
        }
 
        String state = entity.getState();
        if (state != null) {
            stmt.bindString(10, state);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, TaskBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String scanner = entity.getScanner();
        if (scanner != null) {
            stmt.bindString(2, scanner);
        }
 
        String desc = entity.getDesc();
        if (desc != null) {
            stmt.bindString(3, desc);
        }
 
        String taskId = entity.getTaskId();
        if (taskId != null) {
            stmt.bindString(4, taskId);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(5, taskCode);
        }
 
        String markerId = entity.getMarkerId();
        if (markerId != null) {
            stmt.bindString(6, markerId);
        }
 
        String markerRealId = entity.getMarkerRealId();
        if (markerRealId != null) {
            stmt.bindString(7, markerRealId);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(8, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(9, lat);
        }
 
        String state = entity.getState();
        if (state != null) {
            stmt.bindString(10, state);
        }
    }

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

    @Override
    public TaskBean readEntity(Cursor cursor, int offset) {
        TaskBean entity = new TaskBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // scanner
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // desc
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // taskId
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // taskCode
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // markerId
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // markerRealId
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lng
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lat
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9) // state
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, TaskBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setScanner(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setDesc(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setTaskId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setTaskCode(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setMarkerId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setMarkerRealId(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setLng(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setLat(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setState(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(TaskBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(TaskBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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