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

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

    public static final String TABLENAME = "DB_SIGN_LOGCATION_GPS";

    /**
     * Properties of entity LocationGPSDataBean.<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 Longitude = new Property(1, double.class, "longitude", false, "LONGITUDE");
        public final static Property Latitude = new Property(2, double.class, "latitude", false, "LATITUDE");
        public final static Property Date = new Property(3, String.class, "date", false, "DATE");
        public final static Property Gps_time = new Property(4, String.class, "gps_time", false, "GPS_TIME");
        public final static Property Section = new Property(5, long.class, "section", false, "SECTION");
        public final static Property Day = new Property(6, String.class, "day", false, "DAY");
        public final static Property IsValid = new Property(7, int.class, "isValid", false, "IS_VALID");
        public final static Property State = new Property(8, int.class, "state", false, "STATE");
    }


    public LocationGPSDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public LocationGPSDataBeanDao(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_SIGN_LOGCATION_GPS\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"LONGITUDE\" REAL NOT NULL ," + // 1: longitude
                "\"LATITUDE\" REAL NOT NULL ," + // 2: latitude
                "\"DATE\" TEXT," + // 3: date
                "\"GPS_TIME\" TEXT," + // 4: gps_time
                "\"SECTION\" INTEGER NOT NULL ," + // 5: section
                "\"DAY\" TEXT," + // 6: day
                "\"IS_VALID\" INTEGER NOT NULL ," + // 7: isValid
                "\"STATE\" INTEGER NOT NULL );"); // 8: state
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, LocationGPSDataBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindDouble(2, entity.getLongitude());
        stmt.bindDouble(3, entity.getLatitude());
 
        String date = entity.getDate();
        if (date != null) {
            stmt.bindString(4, date);
        }
 
        String gps_time = entity.getGps_time();
        if (gps_time != null) {
            stmt.bindString(5, gps_time);
        }
        stmt.bindLong(6, entity.getSection());
 
        String day = entity.getDay();
        if (day != null) {
            stmt.bindString(7, day);
        }
        stmt.bindLong(8, entity.getIsValid());
        stmt.bindLong(9, entity.getState());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, LocationGPSDataBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
        stmt.bindDouble(2, entity.getLongitude());
        stmt.bindDouble(3, entity.getLatitude());
 
        String date = entity.getDate();
        if (date != null) {
            stmt.bindString(4, date);
        }
 
        String gps_time = entity.getGps_time();
        if (gps_time != null) {
            stmt.bindString(5, gps_time);
        }
        stmt.bindLong(6, entity.getSection());
 
        String day = entity.getDay();
        if (day != null) {
            stmt.bindString(7, day);
        }
        stmt.bindLong(8, entity.getIsValid());
        stmt.bindLong(9, entity.getState());
    }

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

    @Override
    public LocationGPSDataBean readEntity(Cursor cursor, int offset) {
        LocationGPSDataBean entity = new LocationGPSDataBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.getDouble(offset + 1), // longitude
            cursor.getDouble(offset + 2), // latitude
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // date
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // gps_time
            cursor.getLong(offset + 5), // section
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // day
            cursor.getInt(offset + 7), // isValid
            cursor.getInt(offset + 8) // state
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, LocationGPSDataBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setLongitude(cursor.getDouble(offset + 1));
        entity.setLatitude(cursor.getDouble(offset + 2));
        entity.setDate(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setGps_time(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setSection(cursor.getLong(offset + 5));
        entity.setDay(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setIsValid(cursor.getInt(offset + 7));
        entity.setState(cursor.getInt(offset + 8));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(LocationGPSDataBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(LocationGPSDataBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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