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

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

    public static final String TABLENAME = "TOILET_LIST_BEAN";

    /**
     * Properties of entity ToiletListBean.<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 Area = new Property(1, String.class, "area", false, "AREA");
        public final static Property Code = new Property(2, String.class, "code", false, "CODE");
        public final static Property CreateTime = new Property(3, String.class, "createTime", false, "CREATE_TIME");
        public final static Property DelFlag = new Property(4, String.class, "delFlag", false, "DEL_FLAG");
        public final static Property DeptId = new Property(5, String.class, "deptId", false, "DEPT_ID");
        public final static Property ToiletId = new Property(6, String.class, "toiletId", false, "TOILET_ID");
        public final static Property Lat = new Property(7, String.class, "lat", false, "LAT");
        public final static Property Lng = new Property(8, String.class, "lng", false, "LNG");
        public final static Property Name = new Property(9, String.class, "name", false, "NAME");
        public final static Property Notes = new Property(10, String.class, "notes", false, "NOTES");
        public final static Property Owner = new Property(11, String.class, "owner", false, "OWNER");
        public final static Property Photo = new Property(12, String.class, "photo", false, "PHOTO");
        public final static Property Position = new Property(13, String.class, "position", false, "POSITION");
        public final static Property ResponsiblePerson = new Property(14, String.class, "responsiblePerson", false, "RESPONSIBLE_PERSON");
        public final static Property ResponsiblePersonTel = new Property(15, String.class, "responsiblePersonTel", false, "RESPONSIBLE_PERSON_TEL");
        public final static Property Ts = new Property(16, String.class, "ts", false, "TS");
        public final static Property UpdateTime = new Property(17, String.class, "updateTime", false, "UPDATE_TIME");
    }


    public ToiletListBeanDao(DaoConfig config) {
        super(config);
    }
    
    public ToiletListBeanDao(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 + "\"TOILET_LIST_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"AREA\" TEXT," + // 1: area
                "\"CODE\" TEXT," + // 2: code
                "\"CREATE_TIME\" TEXT," + // 3: createTime
                "\"DEL_FLAG\" TEXT," + // 4: delFlag
                "\"DEPT_ID\" TEXT," + // 5: deptId
                "\"TOILET_ID\" TEXT," + // 6: toiletId
                "\"LAT\" TEXT," + // 7: lat
                "\"LNG\" TEXT," + // 8: lng
                "\"NAME\" TEXT," + // 9: name
                "\"NOTES\" TEXT," + // 10: notes
                "\"OWNER\" TEXT," + // 11: owner
                "\"PHOTO\" TEXT," + // 12: photo
                "\"POSITION\" TEXT," + // 13: position
                "\"RESPONSIBLE_PERSON\" TEXT," + // 14: responsiblePerson
                "\"RESPONSIBLE_PERSON_TEL\" TEXT," + // 15: responsiblePersonTel
                "\"TS\" TEXT," + // 16: ts
                "\"UPDATE_TIME\" TEXT);"); // 17: updateTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, ToiletListBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String area = entity.getArea();
        if (area != null) {
            stmt.bindString(2, area);
        }
 
        String code = entity.getCode();
        if (code != null) {
            stmt.bindString(3, code);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(4, createTime);
        }
 
        String delFlag = entity.getDelFlag();
        if (delFlag != null) {
            stmt.bindString(5, delFlag);
        }
 
        String deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindString(6, deptId);
        }
 
        String toiletId = entity.getToiletId();
        if (toiletId != null) {
            stmt.bindString(7, toiletId);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(8, lat);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(9, lng);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(10, name);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(11, notes);
        }
 
        String owner = entity.getOwner();
        if (owner != null) {
            stmt.bindString(12, owner);
        }
 
        String photo = entity.getPhoto();
        if (photo != null) {
            stmt.bindString(13, photo);
        }
 
        String position = entity.getPosition();
        if (position != null) {
            stmt.bindString(14, position);
        }
 
        String responsiblePerson = entity.getResponsiblePerson();
        if (responsiblePerson != null) {
            stmt.bindString(15, responsiblePerson);
        }
 
        String responsiblePersonTel = entity.getResponsiblePersonTel();
        if (responsiblePersonTel != null) {
            stmt.bindString(16, responsiblePersonTel);
        }
 
        String ts = entity.getTs();
        if (ts != null) {
            stmt.bindString(17, ts);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(18, updateTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, ToiletListBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String area = entity.getArea();
        if (area != null) {
            stmt.bindString(2, area);
        }
 
        String code = entity.getCode();
        if (code != null) {
            stmt.bindString(3, code);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(4, createTime);
        }
 
        String delFlag = entity.getDelFlag();
        if (delFlag != null) {
            stmt.bindString(5, delFlag);
        }
 
        String deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindString(6, deptId);
        }
 
        String toiletId = entity.getToiletId();
        if (toiletId != null) {
            stmt.bindString(7, toiletId);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(8, lat);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(9, lng);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(10, name);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(11, notes);
        }
 
        String owner = entity.getOwner();
        if (owner != null) {
            stmt.bindString(12, owner);
        }
 
        String photo = entity.getPhoto();
        if (photo != null) {
            stmt.bindString(13, photo);
        }
 
        String position = entity.getPosition();
        if (position != null) {
            stmt.bindString(14, position);
        }
 
        String responsiblePerson = entity.getResponsiblePerson();
        if (responsiblePerson != null) {
            stmt.bindString(15, responsiblePerson);
        }
 
        String responsiblePersonTel = entity.getResponsiblePersonTel();
        if (responsiblePersonTel != null) {
            stmt.bindString(16, responsiblePersonTel);
        }
 
        String ts = entity.getTs();
        if (ts != null) {
            stmt.bindString(17, ts);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(18, updateTime);
        }
    }

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

    @Override
    public ToiletListBean readEntity(Cursor cursor, int offset) {
        ToiletListBean entity = new ToiletListBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // area
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // code
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // createTime
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // delFlag
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // deptId
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // toiletId
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // lat
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // lng
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // name
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // notes
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // owner
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // photo
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // position
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // responsiblePerson
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // responsiblePersonTel
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // ts
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17) // updateTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, ToiletListBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setArea(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setCode(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCreateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDelFlag(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setToiletId(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setLat(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setLng(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setName(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setNotes(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setOwner(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setPhoto(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setPosition(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setResponsiblePerson(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setResponsiblePersonTel(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setTs(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setUpdateTime(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(ToiletListBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(ToiletListBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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