package com.tofly.data.sql.dao;

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.tofly.ghrq_route.module.gps.domain.CheckGPSDataBean;

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

    public static final String TABLENAME = "DB_LAST_GPS_SAVED";

    /**
     * Properties of entity CheckGPSDataBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Gps_id = new Property(0, String.class, "gps_id", true, "GPS_ID");
        public final static Property Lng = new Property(1, String.class, "lng", false, "LNG");
        public final static Property Lat = new Property(2, String.class, "lat", false, "LAT");
        public final static Property Gpstime = new Property(3, String.class, "gpstime", false, "GPSTIME");
        public final static Property Check_time = new Property(4, String.class, "check_time", false, "CHECK_TIME");
        public final static Property Gps_type = new Property(5, int.class, "gps_type", false, "GPS_TYPE");
        public final static Property Carid = new Property(6, String.class, "carid", false, "CARID");
        public final static Property IsValid = new Property(7, int.class, "isValid", false, "IS_VALID");
        public final static Property Section = new Property(8, long.class, "section", false, "SECTION");
        public final static Property Timespan = new Property(9, long.class, "timespan", false, "TIMESPAN");
        public final static Property State = new Property(10, int.class, "state", false, "STATE");
    }


    public CheckGPSDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public CheckGPSDataBeanDao(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 + "\"DB_LAST_GPS_SAVED\" (" + //
                "\"GPS_ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: gps_id
                "\"LNG\" TEXT," + // 1: lng
                "\"LAT\" TEXT," + // 2: lat
                "\"GPSTIME\" TEXT," + // 3: gpstime
                "\"CHECK_TIME\" TEXT," + // 4: check_time
                "\"GPS_TYPE\" INTEGER NOT NULL ," + // 5: gps_type
                "\"CARID\" TEXT," + // 6: carid
                "\"IS_VALID\" INTEGER NOT NULL ," + // 7: isValid
                "\"SECTION\" INTEGER NOT NULL ," + // 8: section
                "\"TIMESPAN\" INTEGER NOT NULL ," + // 9: timespan
                "\"STATE\" INTEGER NOT NULL );"); // 10: state
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, CheckGPSDataBean entity) {
        stmt.clearBindings();
 
        String gps_id = entity.getGps_id();
        if (gps_id != null) {
            stmt.bindString(1, gps_id);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(2, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(3, lat);
        }
 
        String gpstime = entity.getGpstime();
        if (gpstime != null) {
            stmt.bindString(4, gpstime);
        }
 
        String check_time = entity.getCheck_time();
        if (check_time != null) {
            stmt.bindString(5, check_time);
        }
        stmt.bindLong(6, entity.getGps_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(7, carid);
        }
        stmt.bindLong(8, entity.getIsValid());
        stmt.bindLong(9, entity.getSection());
        stmt.bindLong(10, entity.getTimespan());
        stmt.bindLong(11, entity.getState());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, CheckGPSDataBean entity) {
        stmt.clearBindings();
 
        String gps_id = entity.getGps_id();
        if (gps_id != null) {
            stmt.bindString(1, gps_id);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(2, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(3, lat);
        }
 
        String gpstime = entity.getGpstime();
        if (gpstime != null) {
            stmt.bindString(4, gpstime);
        }
 
        String check_time = entity.getCheck_time();
        if (check_time != null) {
            stmt.bindString(5, check_time);
        }
        stmt.bindLong(6, entity.getGps_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(7, carid);
        }
        stmt.bindLong(8, entity.getIsValid());
        stmt.bindLong(9, entity.getSection());
        stmt.bindLong(10, entity.getTimespan());
        stmt.bindLong(11, entity.getState());
    }

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

    @Override
    public CheckGPSDataBean readEntity(Cursor cursor, int offset) {
        CheckGPSDataBean entity = new CheckGPSDataBean( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // gps_id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // lng
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lat
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // gpstime
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // check_time
            cursor.getInt(offset + 5), // gps_type
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // carid
            cursor.getInt(offset + 7), // isValid
            cursor.getLong(offset + 8), // section
            cursor.getLong(offset + 9), // timespan
            cursor.getInt(offset + 10) // state
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, CheckGPSDataBean entity, int offset) {
        entity.setGps_id(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setLng(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setLat(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setGpstime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCheck_time(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setGps_type(cursor.getInt(offset + 5));
        entity.setCarid(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setIsValid(cursor.getInt(offset + 7));
        entity.setSection(cursor.getLong(offset + 8));
        entity.setTimespan(cursor.getLong(offset + 9));
        entity.setState(cursor.getInt(offset + 10));
     }
    
    @Override
    protected final String updateKeyAfterInsert(CheckGPSDataBean entity, long rowId) {
        return entity.getGps_id();
    }
    
    @Override
    public String getKey(CheckGPSDataBean entity) {
        if(entity != null) {
            return entity.getGps_id();
        } else {
            return null;
        }
    }

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

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