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.deviceInfo.domain.DeviceInfoBean;

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

    public static final String TABLENAME = "DB_DEVICEINFO_SAVED";

    /**
     * Properties of entity DeviceInfoBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, String.class, "id", true, "ID");
        public final static Property Gps_state = new Property(1, int.class, "gps_state", false, "GPS_STATE");
        public final static Property Gps_precision = new Property(2, String.class, "gps_precision", false, "GPS_PRECISION");
        public final static Property Gps_star = new Property(3, int.class, "gps_star", false, "GPS_STAR");
        public final static Property Network_type = new Property(4, int.class, "network_type", false, "NETWORK_TYPE");
        public final static Property Network_state = new Property(5, int.class, "network_state", false, "NETWORK_STATE");
        public final static Property Gps_type = new Property(6, int.class, "gps_type", false, "GPS_TYPE");
        public final static Property Carid = new Property(7, String.class, "carid", false, "CARID");
        public final static Property Electricity = new Property(8, int.class, "electricity", false, "ELECTRICITY");
        public final static Property Check_time = new Property(9, String.class, "check_time", false, "CHECK_TIME");
        public final static Property Note = new Property(10, String.class, "note", false, "NOTE");
        public final static Property Residual_space = new Property(11, String.class, "residual_space", false, "RESIDUAL_SPACE");
    }


    public DeviceInfoBeanDao(DaoConfig config) {
        super(config);
    }
    
    public DeviceInfoBeanDao(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_DEVICEINFO_SAVED\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: id
                "\"GPS_STATE\" INTEGER NOT NULL ," + // 1: gps_state
                "\"GPS_PRECISION\" TEXT," + // 2: gps_precision
                "\"GPS_STAR\" INTEGER NOT NULL ," + // 3: gps_star
                "\"NETWORK_TYPE\" INTEGER NOT NULL ," + // 4: network_type
                "\"NETWORK_STATE\" INTEGER NOT NULL ," + // 5: network_state
                "\"GPS_TYPE\" INTEGER NOT NULL ," + // 6: gps_type
                "\"CARID\" TEXT," + // 7: carid
                "\"ELECTRICITY\" INTEGER NOT NULL ," + // 8: electricity
                "\"CHECK_TIME\" TEXT," + // 9: check_time
                "\"NOTE\" TEXT," + // 10: note
                "\"RESIDUAL_SPACE\" TEXT);"); // 11: residual_space
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, DeviceInfoBean entity) {
        stmt.clearBindings();
 
        String id = entity.getId();
        if (id != null) {
            stmt.bindString(1, id);
        }
        stmt.bindLong(2, entity.getGps_state());
 
        String gps_precision = entity.getGps_precision();
        if (gps_precision != null) {
            stmt.bindString(3, gps_precision);
        }
        stmt.bindLong(4, entity.getGps_star());
        stmt.bindLong(5, entity.getNetwork_type());
        stmt.bindLong(6, entity.getNetwork_state());
        stmt.bindLong(7, entity.getGps_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(8, carid);
        }
        stmt.bindLong(9, entity.getElectricity());
 
        String check_time = entity.getCheck_time();
        if (check_time != null) {
            stmt.bindString(10, check_time);
        }
 
        String note = entity.getNote();
        if (note != null) {
            stmt.bindString(11, note);
        }
 
        String residual_space = entity.getResidual_space();
        if (residual_space != null) {
            stmt.bindString(12, residual_space);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, DeviceInfoBean entity) {
        stmt.clearBindings();
 
        String id = entity.getId();
        if (id != null) {
            stmt.bindString(1, id);
        }
        stmt.bindLong(2, entity.getGps_state());
 
        String gps_precision = entity.getGps_precision();
        if (gps_precision != null) {
            stmt.bindString(3, gps_precision);
        }
        stmt.bindLong(4, entity.getGps_star());
        stmt.bindLong(5, entity.getNetwork_type());
        stmt.bindLong(6, entity.getNetwork_state());
        stmt.bindLong(7, entity.getGps_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(8, carid);
        }
        stmt.bindLong(9, entity.getElectricity());
 
        String check_time = entity.getCheck_time();
        if (check_time != null) {
            stmt.bindString(10, check_time);
        }
 
        String note = entity.getNote();
        if (note != null) {
            stmt.bindString(11, note);
        }
 
        String residual_space = entity.getResidual_space();
        if (residual_space != null) {
            stmt.bindString(12, residual_space);
        }
    }

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

    @Override
    public DeviceInfoBean readEntity(Cursor cursor, int offset) {
        DeviceInfoBean entity = new DeviceInfoBean( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // id
            cursor.getInt(offset + 1), // gps_state
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // gps_precision
            cursor.getInt(offset + 3), // gps_star
            cursor.getInt(offset + 4), // network_type
            cursor.getInt(offset + 5), // network_state
            cursor.getInt(offset + 6), // gps_type
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // carid
            cursor.getInt(offset + 8), // electricity
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // check_time
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // note
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11) // residual_space
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, DeviceInfoBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setGps_state(cursor.getInt(offset + 1));
        entity.setGps_precision(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setGps_star(cursor.getInt(offset + 3));
        entity.setNetwork_type(cursor.getInt(offset + 4));
        entity.setNetwork_state(cursor.getInt(offset + 5));
        entity.setGps_type(cursor.getInt(offset + 6));
        entity.setCarid(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setElectricity(cursor.getInt(offset + 8));
        entity.setCheck_time(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setNote(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setResidual_space(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
     }
    
    @Override
    protected final String updateKeyAfterInsert(DeviceInfoBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(DeviceInfoBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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