package com.phlx.anchorcollect_p.db.gen;

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.phlx.anchorcollect_p.entity.WeightManEntity;

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

    public static final String TABLENAME = "WEIGHT_MAN_ENTITY";

    /**
     * Properties of entity WeightManEntity.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Unid = new Property(0, Long.class, "unid", true, "_id");
        public final static Property CattleresumeId = new Property(1, Long.class, "cattleresumeId", false, "CATTLERESUME_ID");
        public final static Property Weight = new Property(2, Double.class, "weight", false, "WEIGHT");
        public final static Property WTime = new Property(3, String.class, "wTime", false, "W_TIME");
        public final static Property UploadStatus = new Property(4, String.class, "uploadStatus", false, "UPLOAD_STATUS");
        public final static Property DeptId = new Property(5, Long.class, "deptId", false, "DEPT_ID");
        public final static Property SearchValue = new Property(6, String.class, "searchValue", false, "SEARCH_VALUE");
        public final static Property CreateBy = new Property(7, String.class, "createBy", false, "CREATE_BY");
        public final static Property CreateTime = new Property(8, String.class, "createTime", false, "CREATE_TIME");
        public final static Property UpdateBy = new Property(9, String.class, "updateBy", false, "UPDATE_BY");
        public final static Property UpdateTime = new Property(10, String.class, "updateTime", false, "UPDATE_TIME");
        public final static Property Remark = new Property(11, String.class, "remark", false, "REMARK");
    }


    public WeightManEntityDao(DaoConfig config) {
        super(config);
    }
    
    public WeightManEntityDao(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 + "\"WEIGHT_MAN_ENTITY\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: unid
                "\"CATTLERESUME_ID\" INTEGER," + // 1: cattleresumeId
                "\"WEIGHT\" REAL," + // 2: weight
                "\"W_TIME\" TEXT," + // 3: wTime
                "\"UPLOAD_STATUS\" TEXT," + // 4: uploadStatus
                "\"DEPT_ID\" INTEGER," + // 5: deptId
                "\"SEARCH_VALUE\" TEXT," + // 6: searchValue
                "\"CREATE_BY\" TEXT," + // 7: createBy
                "\"CREATE_TIME\" TEXT," + // 8: createTime
                "\"UPDATE_BY\" TEXT," + // 9: updateBy
                "\"UPDATE_TIME\" TEXT," + // 10: updateTime
                "\"REMARK\" TEXT);"); // 11: remark
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, WeightManEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long cattleresumeId = entity.getCattleresumeId();
        if (cattleresumeId != null) {
            stmt.bindLong(2, cattleresumeId);
        }
 
        Double weight = entity.getWeight();
        if (weight != null) {
            stmt.bindDouble(3, weight);
        }
 
        String wTime = entity.getWTime();
        if (wTime != null) {
            stmt.bindString(4, wTime);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(5, uploadStatus);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(6, deptId);
        }
 
        String searchValue = entity.getSearchValue();
        if (searchValue != null) {
            stmt.bindString(7, searchValue);
        }
 
        String createBy = entity.getCreateBy();
        if (createBy != null) {
            stmt.bindString(8, createBy);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(9, createTime);
        }
 
        String updateBy = entity.getUpdateBy();
        if (updateBy != null) {
            stmt.bindString(10, updateBy);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(11, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(12, remark);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, WeightManEntity entity) {
        stmt.clearBindings();
 
        Long unid = entity.getUnid();
        if (unid != null) {
            stmt.bindLong(1, unid);
        }
 
        Long cattleresumeId = entity.getCattleresumeId();
        if (cattleresumeId != null) {
            stmt.bindLong(2, cattleresumeId);
        }
 
        Double weight = entity.getWeight();
        if (weight != null) {
            stmt.bindDouble(3, weight);
        }
 
        String wTime = entity.getWTime();
        if (wTime != null) {
            stmt.bindString(4, wTime);
        }
 
        String uploadStatus = entity.getUploadStatus();
        if (uploadStatus != null) {
            stmt.bindString(5, uploadStatus);
        }
 
        Long deptId = entity.getDeptId();
        if (deptId != null) {
            stmt.bindLong(6, deptId);
        }
 
        String searchValue = entity.getSearchValue();
        if (searchValue != null) {
            stmt.bindString(7, searchValue);
        }
 
        String createBy = entity.getCreateBy();
        if (createBy != null) {
            stmt.bindString(8, createBy);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(9, createTime);
        }
 
        String updateBy = entity.getUpdateBy();
        if (updateBy != null) {
            stmt.bindString(10, updateBy);
        }
 
        String updateTime = entity.getUpdateTime();
        if (updateTime != null) {
            stmt.bindString(11, updateTime);
        }
 
        String remark = entity.getRemark();
        if (remark != null) {
            stmt.bindString(12, remark);
        }
    }

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

    @Override
    public WeightManEntity readEntity(Cursor cursor, int offset) {
        WeightManEntity entity = new WeightManEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // unid
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // cattleresumeId
            cursor.isNull(offset + 2) ? null : cursor.getDouble(offset + 2), // weight
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // wTime
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // uploadStatus
            cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // deptId
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // searchValue
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // createBy
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // createTime
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // updateBy
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // updateTime
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11) // remark
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, WeightManEntity entity, int offset) {
        entity.setUnid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setCattleresumeId(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setWeight(cursor.isNull(offset + 2) ? null : cursor.getDouble(offset + 2));
        entity.setWTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setUploadStatus(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setDeptId(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5));
        entity.setSearchValue(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setCreateBy(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setCreateTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setUpdateBy(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setUpdateTime(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setRemark(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(WeightManEntity entity, long rowId) {
        entity.setUnid(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(WeightManEntity entity) {
        if(entity != null) {
            return entity.getUnid();
        } else {
            return null;
        }
    }

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

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