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

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

    public static final String TABLENAME = "DB_GPS_SAVED";

    /**
     * Properties of entity GPSDataBean.<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 Address = new Property(3, String.class, "address", false, "ADDRESS");
        public final static Property Direction = new Property(4, String.class, "direction", false, "DIRECTION");
        public final static Property Speed = new Property(5, String.class, "speed", false, "SPEED");
        public final static Property Distance = new Property(6, String.class, "distance", false, "DISTANCE");
        public final static Property Gps_timespan = new Property(7, String.class, "gps_timespan", false, "GPS_TIMESPAN");
        public final static Property Gps_speed = new Property(8, String.class, "gps_speed", false, "GPS_SPEED");
        public final static Property Network = new Property(9, int.class, "network", false, "NETWORK");
        public final static Property Gpstime = new Property(10, String.class, "gpstime", false, "GPSTIME");
        public final static Property Check_time = new Property(11, String.class, "check_time", false, "CHECK_TIME");
        public final static Property Gps_type = new Property(12, int.class, "gps_type", false, "GPS_TYPE");
        public final static Property Carid = new Property(13, String.class, "carid", false, "CARID");
        public final static Property Gps_star = new Property(14, int.class, "gps_star", false, "GPS_STAR");
        public final static Property Gps_precision = new Property(15, String.class, "gps_precision", false, "GPS_PRECISION");
        public final static Property Notes = new Property(16, String.class, "notes", false, "NOTES");
        public final static Property IsValid = new Property(17, int.class, "isValid", false, "IS_VALID");
        public final static Property Section = new Property(18, long.class, "section", false, "SECTION");
        public final static Property State = new Property(19, int.class, "state", false, "STATE");
        public final static Property Sid = new Property(20, long.class, "sid", false, "SID");
    }


    public GPSDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public GPSDataBeanDao(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_GPS_SAVED\" (" + //
                "\"GPS_ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: gps_id
                "\"LNG\" TEXT," + // 1: lng
                "\"LAT\" TEXT," + // 2: lat
                "\"ADDRESS\" TEXT," + // 3: address
                "\"DIRECTION\" TEXT," + // 4: direction
                "\"SPEED\" TEXT," + // 5: speed
                "\"DISTANCE\" TEXT," + // 6: distance
                "\"GPS_TIMESPAN\" TEXT," + // 7: gps_timespan
                "\"GPS_SPEED\" TEXT," + // 8: gps_speed
                "\"NETWORK\" INTEGER NOT NULL ," + // 9: network
                "\"GPSTIME\" TEXT," + // 10: gpstime
                "\"CHECK_TIME\" TEXT," + // 11: check_time
                "\"GPS_TYPE\" INTEGER NOT NULL ," + // 12: gps_type
                "\"CARID\" TEXT," + // 13: carid
                "\"GPS_STAR\" INTEGER NOT NULL ," + // 14: gps_star
                "\"GPS_PRECISION\" TEXT," + // 15: gps_precision
                "\"NOTES\" TEXT," + // 16: notes
                "\"IS_VALID\" INTEGER NOT NULL ," + // 17: isValid
                "\"SECTION\" INTEGER NOT NULL ," + // 18: section
                "\"STATE\" INTEGER NOT NULL ," + // 19: state
                "\"SID\" INTEGER NOT NULL );"); // 20: sid
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, GPSDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getGps_id());
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(2, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(3, lat);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(4, address);
        }
 
        String direction = entity.getDirection();
        if (direction != null) {
            stmt.bindString(5, direction);
        }
 
        String speed = entity.getSpeed();
        if (speed != null) {
            stmt.bindString(6, speed);
        }
 
        String distance = entity.getDistance();
        if (distance != null) {
            stmt.bindString(7, distance);
        }
 
        String gps_timespan = entity.getGps_timespan();
        if (gps_timespan != null) {
            stmt.bindString(8, gps_timespan);
        }
 
        String gps_speed = entity.getGps_speed();
        if (gps_speed != null) {
            stmt.bindString(9, gps_speed);
        }
        stmt.bindLong(10, entity.getNetwork());
 
        String gpstime = entity.getGpstime();
        if (gpstime != null) {
            stmt.bindString(11, gpstime);
        }
 
        String check_time = entity.getCheck_time();
        if (check_time != null) {
            stmt.bindString(12, check_time);
        }
        stmt.bindLong(13, entity.getGps_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(14, carid);
        }
        stmt.bindLong(15, entity.getGps_star());
 
        String gps_precision = entity.getGps_precision();
        if (gps_precision != null) {
            stmt.bindString(16, gps_precision);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(17, notes);
        }
        stmt.bindLong(18, entity.getIsValid());
        stmt.bindLong(19, entity.getSection());
        stmt.bindLong(20, entity.getState());
        stmt.bindLong(21, entity.getSid());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, GPSDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getGps_id());
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(2, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(3, lat);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(4, address);
        }
 
        String direction = entity.getDirection();
        if (direction != null) {
            stmt.bindString(5, direction);
        }
 
        String speed = entity.getSpeed();
        if (speed != null) {
            stmt.bindString(6, speed);
        }
 
        String distance = entity.getDistance();
        if (distance != null) {
            stmt.bindString(7, distance);
        }
 
        String gps_timespan = entity.getGps_timespan();
        if (gps_timespan != null) {
            stmt.bindString(8, gps_timespan);
        }
 
        String gps_speed = entity.getGps_speed();
        if (gps_speed != null) {
            stmt.bindString(9, gps_speed);
        }
        stmt.bindLong(10, entity.getNetwork());
 
        String gpstime = entity.getGpstime();
        if (gpstime != null) {
            stmt.bindString(11, gpstime);
        }
 
        String check_time = entity.getCheck_time();
        if (check_time != null) {
            stmt.bindString(12, check_time);
        }
        stmt.bindLong(13, entity.getGps_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(14, carid);
        }
        stmt.bindLong(15, entity.getGps_star());
 
        String gps_precision = entity.getGps_precision();
        if (gps_precision != null) {
            stmt.bindString(16, gps_precision);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(17, notes);
        }
        stmt.bindLong(18, entity.getIsValid());
        stmt.bindLong(19, entity.getSection());
        stmt.bindLong(20, entity.getState());
        stmt.bindLong(21, entity.getSid());
    }

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

    @Override
    public GPSDataBean readEntity(Cursor cursor, int offset) {
        GPSDataBean entity = new GPSDataBean( //
            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), // address
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // direction
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // speed
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // distance
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // gps_timespan
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // gps_speed
            cursor.getInt(offset + 9), // network
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // gpstime
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // check_time
            cursor.getInt(offset + 12), // gps_type
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // carid
            cursor.getInt(offset + 14), // gps_star
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // gps_precision
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // notes
            cursor.getInt(offset + 17), // isValid
            cursor.getLong(offset + 18), // section
            cursor.getInt(offset + 19), // state
            cursor.getLong(offset + 20) // sid
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, GPSDataBean entity, int offset) {
        entity.setGps_id(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.setAddress(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDirection(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setSpeed(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setDistance(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setGps_timespan(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setGps_speed(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setNetwork(cursor.getInt(offset + 9));
        entity.setGpstime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setCheck_time(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setGps_type(cursor.getInt(offset + 12));
        entity.setCarid(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setGps_star(cursor.getInt(offset + 14));
        entity.setGps_precision(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setNotes(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setIsValid(cursor.getInt(offset + 17));
        entity.setSection(cursor.getLong(offset + 18));
        entity.setState(cursor.getInt(offset + 19));
        entity.setSid(cursor.getLong(offset + 20));
     }
    
    @Override
    protected final String updateKeyAfterInsert(GPSDataBean entity, long rowId) {
        return entity.getGps_id();
    }
    
    @Override
    public String getKey(GPSDataBean entity) {
        if(entity != null) {
            return entity.getGps_id();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(GPSDataBean entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

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