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

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

    public static final String TABLENAME = "TASK_MARKER_LOCAL_BEAN";

    /**
     * Properties of entity TaskMarkerLocalBean.<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 TaskId = new Property(1, String.class, "taskId", false, "TASK_ID");
        public final static Property TaskCode = new Property(2, String.class, "taskCode", false, "TASK_CODE");
        public final static Property MarkerId = new Property(3, String.class, "markerId", false, "MARKER_ID");
        public final static Property Lng = new Property(4, double.class, "lng", false, "LNG");
        public final static Property Lat = new Property(5, double.class, "lat", false, "LAT");
        public final static Property IsDetected = new Property(6, String.class, "isDetected", false, "IS_DETECTED");
        public final static Property DetectedTime = new Property(7, String.class, "detectedTime", false, "DETECTED_TIME");
    }


    public TaskMarkerLocalBeanDao(DaoConfig config) {
        super(config);
    }
    
    public TaskMarkerLocalBeanDao(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_MARKER_LOCAL_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"TASK_ID\" TEXT," + // 1: taskId
                "\"TASK_CODE\" TEXT," + // 2: taskCode
                "\"MARKER_ID\" TEXT," + // 3: markerId
                "\"LNG\" REAL NOT NULL ," + // 4: lng
                "\"LAT\" REAL NOT NULL ," + // 5: lat
                "\"IS_DETECTED\" TEXT," + // 6: isDetected
                "\"DETECTED_TIME\" TEXT);"); // 7: detectedTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, TaskMarkerLocalBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String taskId = entity.getTaskId();
        if (taskId != null) {
            stmt.bindString(2, taskId);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(3, taskCode);
        }
 
        String markerId = entity.getMarkerId();
        if (markerId != null) {
            stmt.bindString(4, markerId);
        }
        stmt.bindDouble(5, entity.getLng());
        stmt.bindDouble(6, entity.getLat());
 
        String isDetected = entity.getIsDetected();
        if (isDetected != null) {
            stmt.bindString(7, isDetected);
        }
 
        String detectedTime = entity.getDetectedTime();
        if (detectedTime != null) {
            stmt.bindString(8, detectedTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, TaskMarkerLocalBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String taskId = entity.getTaskId();
        if (taskId != null) {
            stmt.bindString(2, taskId);
        }
 
        String taskCode = entity.getTaskCode();
        if (taskCode != null) {
            stmt.bindString(3, taskCode);
        }
 
        String markerId = entity.getMarkerId();
        if (markerId != null) {
            stmt.bindString(4, markerId);
        }
        stmt.bindDouble(5, entity.getLng());
        stmt.bindDouble(6, entity.getLat());
 
        String isDetected = entity.getIsDetected();
        if (isDetected != null) {
            stmt.bindString(7, isDetected);
        }
 
        String detectedTime = entity.getDetectedTime();
        if (detectedTime != null) {
            stmt.bindString(8, detectedTime);
        }
    }

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

    @Override
    public TaskMarkerLocalBean readEntity(Cursor cursor, int offset) {
        TaskMarkerLocalBean entity = new TaskMarkerLocalBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // taskId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // taskCode
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // markerId
            cursor.getDouble(offset + 4), // lng
            cursor.getDouble(offset + 5), // lat
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // isDetected
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // detectedTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, TaskMarkerLocalBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setTaskId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setTaskCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setMarkerId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setLng(cursor.getDouble(offset + 4));
        entity.setLat(cursor.getDouble(offset + 5));
        entity.setIsDetected(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setDetectedTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(TaskMarkerLocalBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(TaskMarkerLocalBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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