package com.casic.dcms.greendao;

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.casic.dcms.bean.StreetLightLocalBean;

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

    public static final String TABLENAME = "STREET_LIGHT_LOCAL_BEAN";

    /**
     * Properties of entity StreetLightLocalBean.<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 ControllerCode = new Property(1, String.class, "controllerCode", false, "CONTROLLER_CODE");
        public final static Property LampCode = new Property(2, String.class, "lampCode", false, "LAMP_CODE");
        public final static Property LampId = new Property(3, String.class, "lampId", false, "LAMP_ID");
        public final static Property Latitude = new Property(4, double.class, "latitude", false, "LATITUDE");
        public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID");
        public final static Property StatusName = new Property(6, String.class, "statusName", false, "STATUS_NAME");
        public final static Property LampName = new Property(7, String.class, "lampName", false, "LAMP_NAME");
        public final static Property LatestTime = new Property(8, String.class, "latestTime", false, "LATEST_TIME");
        public final static Property Longitude = new Property(9, double.class, "longitude", false, "LONGITUDE");
        public final static Property Status = new Property(10, String.class, "status", false, "STATUS");
    }


    public StreetLightLocalBeanDao(DaoConfig config) {
        super(config);
    }
    
    public StreetLightLocalBeanDao(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 + "\"STREET_LIGHT_LOCAL_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"CONTROLLER_CODE\" TEXT," + // 1: controllerCode
                "\"LAMP_CODE\" TEXT," + // 2: lampCode
                "\"LAMP_ID\" TEXT," + // 3: lampId
                "\"LATITUDE\" REAL NOT NULL ," + // 4: latitude
                "\"DEPT_ID\" TEXT," + // 5: deptId
                "\"STATUS_NAME\" TEXT," + // 6: statusName
                "\"LAMP_NAME\" TEXT," + // 7: lampName
                "\"LATEST_TIME\" TEXT," + // 8: latestTime
                "\"LONGITUDE\" REAL NOT NULL ," + // 9: longitude
                "\"STATUS\" TEXT);"); // 10: status
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, StreetLightLocalBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String controllerCode = entity.getControllerCode();
        if (controllerCode != null) {
            stmt.bindString(2, controllerCode);
        }
 
        String lampCode = entity.getLampCode();
        if (lampCode != null) {
            stmt.bindString(3, lampCode);
        }
 
        String lampId = entity.getLampId();
        if (lampId != null) {
            stmt.bindString(4, lampId);
        }
        stmt.bindDouble(5, entity.getLatitude());
 
        String deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindString(6, deptId);
        }
 
        String statusName = entity.getStatusName();
        if (statusName != null) {
            stmt.bindString(7, statusName);
        }
 
        String lampName = entity.getLampName();
        if (lampName != null) {
            stmt.bindString(8, lampName);
        }
 
        String latestTime = entity.getLatestTime();
        if (latestTime != null) {
            stmt.bindString(9, latestTime);
        }
        stmt.bindDouble(10, entity.getLongitude());
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(11, status);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, StreetLightLocalBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String controllerCode = entity.getControllerCode();
        if (controllerCode != null) {
            stmt.bindString(2, controllerCode);
        }
 
        String lampCode = entity.getLampCode();
        if (lampCode != null) {
            stmt.bindString(3, lampCode);
        }
 
        String lampId = entity.getLampId();
        if (lampId != null) {
            stmt.bindString(4, lampId);
        }
        stmt.bindDouble(5, entity.getLatitude());
 
        String deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindString(6, deptId);
        }
 
        String statusName = entity.getStatusName();
        if (statusName != null) {
            stmt.bindString(7, statusName);
        }
 
        String lampName = entity.getLampName();
        if (lampName != null) {
            stmt.bindString(8, lampName);
        }
 
        String latestTime = entity.getLatestTime();
        if (latestTime != null) {
            stmt.bindString(9, latestTime);
        }
        stmt.bindDouble(10, entity.getLongitude());
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(11, status);
        }
    }

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

    @Override
    public StreetLightLocalBean readEntity(Cursor cursor, int offset) {
        StreetLightLocalBean entity = new StreetLightLocalBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // controllerCode
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lampCode
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // lampId
            cursor.getDouble(offset + 4), // latitude
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // statusName
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lampName
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // latestTime
            cursor.getDouble(offset + 9), // longitude
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // status
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, StreetLightLocalBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setControllerCode(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setLampCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setLampId(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setLatitude(cursor.getDouble(offset + 4));
        entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setStatusName(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setLampName(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setLatestTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setLongitude(cursor.getDouble(offset + 9));
        entity.setStatus(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(StreetLightLocalBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(StreetLightLocalBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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