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.sign.domain.SignHistoryDataBean;

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

    public static final String TABLENAME = "DB_SIGN_HISTORY";

    /**
     * Properties of entity SignHistoryDataBean.<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 SignType = new Property(1, int.class, "signType", false, "SIGN_TYPE");
        public final static Property Carmode = new Property(2, int.class, "carmode", false, "CARMODE");
        public final static Property Lng = new Property(3, String.class, "lng", false, "LNG");
        public final static Property Lat = new Property(4, String.class, "lat", false, "LAT");
        public final static Property GpsFlag = new Property(5, int.class, "gpsFlag", false, "GPS_FLAG");
        public final static Property SignTime = new Property(6, String.class, "signTime", false, "SIGN_TIME");
        public final static Property SignAddr = new Property(7, String.class, "signAddr", false, "SIGN_ADDR");
        public final static Property DeviceInfoId = new Property(8, String.class, "deviceInfoId", false, "DEVICE_INFO_ID");
        public final static Property PlanIds = new Property(9, String.class, "planIds", false, "PLAN_IDS");
        public final static Property State = new Property(10, int.class, "state", false, "STATE");
        public final static Property IsUpload = new Property(11, int.class, "isUpload", false, "IS_UPLOAD");
        public final static Property Userid = new Property(12, String.class, "userid", false, "USERID");
    }


    public SignHistoryDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public SignHistoryDataBeanDao(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_HISTORY\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"SIGN_TYPE\" INTEGER NOT NULL ," + // 1: signType
                "\"CARMODE\" INTEGER NOT NULL ," + // 2: carmode
                "\"LNG\" TEXT," + // 3: lng
                "\"LAT\" TEXT," + // 4: lat
                "\"GPS_FLAG\" INTEGER NOT NULL ," + // 5: gpsFlag
                "\"SIGN_TIME\" TEXT," + // 6: signTime
                "\"SIGN_ADDR\" TEXT," + // 7: signAddr
                "\"DEVICE_INFO_ID\" TEXT," + // 8: deviceInfoId
                "\"PLAN_IDS\" TEXT," + // 9: planIds
                "\"STATE\" INTEGER NOT NULL ," + // 10: state
                "\"IS_UPLOAD\" INTEGER NOT NULL ," + // 11: isUpload
                "\"USERID\" TEXT);"); // 12: userid
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, SignHistoryDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
        stmt.bindLong(2, entity.getSignType());
        stmt.bindLong(3, entity.getCarmode());
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(4, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(5, lat);
        }
        stmt.bindLong(6, entity.getGpsFlag());
 
        String signTime = entity.getSignTime();
        if (signTime != null) {
            stmt.bindString(7, signTime);
        }
 
        String signAddr = entity.getSignAddr();
        if (signAddr != null) {
            stmt.bindString(8, signAddr);
        }
 
        String deviceInfoId = entity.getDeviceInfoId();
        if (deviceInfoId != null) {
            stmt.bindString(9, deviceInfoId);
        }
 
        String planIds = entity.getPlanIds();
        if (planIds != null) {
            stmt.bindString(10, planIds);
        }
        stmt.bindLong(11, entity.getState());
        stmt.bindLong(12, entity.getIsUpload());
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(13, userid);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SignHistoryDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
        stmt.bindLong(2, entity.getSignType());
        stmt.bindLong(3, entity.getCarmode());
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(4, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(5, lat);
        }
        stmt.bindLong(6, entity.getGpsFlag());
 
        String signTime = entity.getSignTime();
        if (signTime != null) {
            stmt.bindString(7, signTime);
        }
 
        String signAddr = entity.getSignAddr();
        if (signAddr != null) {
            stmt.bindString(8, signAddr);
        }
 
        String deviceInfoId = entity.getDeviceInfoId();
        if (deviceInfoId != null) {
            stmt.bindString(9, deviceInfoId);
        }
 
        String planIds = entity.getPlanIds();
        if (planIds != null) {
            stmt.bindString(10, planIds);
        }
        stmt.bindLong(11, entity.getState());
        stmt.bindLong(12, entity.getIsUpload());
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(13, userid);
        }
    }

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

    @Override
    public SignHistoryDataBean readEntity(Cursor cursor, int offset) {
        SignHistoryDataBean entity = new SignHistoryDataBean( //
            cursor.getString(offset + 0), // id
            cursor.getInt(offset + 1), // signType
            cursor.getInt(offset + 2), // carmode
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lng
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // lat
            cursor.getInt(offset + 5), // gpsFlag
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // signTime
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // signAddr
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // deviceInfoId
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // planIds
            cursor.getInt(offset + 10), // state
            cursor.getInt(offset + 11), // isUpload
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12) // userid
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SignHistoryDataBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setSignType(cursor.getInt(offset + 1));
        entity.setCarmode(cursor.getInt(offset + 2));
        entity.setLng(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setLat(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setGpsFlag(cursor.getInt(offset + 5));
        entity.setSignTime(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setSignAddr(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setDeviceInfoId(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setPlanIds(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setState(cursor.getInt(offset + 10));
        entity.setIsUpload(cursor.getInt(offset + 11));
        entity.setUserid(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
     }
    
    @Override
    protected final String updateKeyAfterInsert(SignHistoryDataBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(SignHistoryDataBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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