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.planPointRepair.domain.RepairSysDeviceSetting;

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

    public static final String TABLENAME = "SYS_REPAIR_DEVICE_SETTING";

    /**
     * Properties of entity RepairSysDeviceSetting.<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 Input_type = new Property(1, int.class, "input_type", false, "INPUT_TYPE");
        public final static Property Cnname = new Property(2, String.class, "cnname", false, "CNNAME");
        public final static Property Enname = new Property(3, String.class, "enname", false, "ENNAME");
        public final static Property Para_type = new Property(4, int.class, "para_type", false, "PARA_TYPE");
        public final static Property Isphoto = new Property(5, int.class, "isphoto", false, "ISPHOTO");
        public final static Property Para_max = new Property(6, int.class, "para_max", false, "PARA_MAX");
        public final static Property Para_min = new Property(7, int.class, "para_min", false, "PARA_MIN");
        public final static Property Isrange = new Property(8, int.class, "isrange", false, "ISRANGE");
        public final static Property Configkey = new Property(9, String.class, "configkey", false, "CONFIGKEY");
        public final static Property Plan_id = new Property(10, String.class, "plan_id", false, "PLAN_ID");
    }


    public RepairSysDeviceSettingDao(DaoConfig config) {
        super(config);
    }
    
    public RepairSysDeviceSettingDao(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 + "\"SYS_REPAIR_DEVICE_SETTING\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"INPUT_TYPE\" INTEGER NOT NULL ," + // 1: input_type
                "\"CNNAME\" TEXT," + // 2: cnname
                "\"ENNAME\" TEXT," + // 3: enname
                "\"PARA_TYPE\" INTEGER NOT NULL ," + // 4: para_type
                "\"ISPHOTO\" INTEGER NOT NULL ," + // 5: isphoto
                "\"PARA_MAX\" INTEGER NOT NULL ," + // 6: para_max
                "\"PARA_MIN\" INTEGER NOT NULL ," + // 7: para_min
                "\"ISRANGE\" INTEGER NOT NULL ," + // 8: isrange
                "\"CONFIGKEY\" TEXT," + // 9: configkey
                "\"PLAN_ID\" TEXT);"); // 10: plan_id
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, RepairSysDeviceSetting entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
        stmt.bindLong(2, entity.getInput_type());
 
        String cnname = entity.getCnname();
        if (cnname != null) {
            stmt.bindString(3, cnname);
        }
 
        String enname = entity.getEnname();
        if (enname != null) {
            stmt.bindString(4, enname);
        }
        stmt.bindLong(5, entity.getPara_type());
        stmt.bindLong(6, entity.getIsphoto());
        stmt.bindLong(7, entity.getPara_max());
        stmt.bindLong(8, entity.getPara_min());
        stmt.bindLong(9, entity.getIsrange());
 
        String configkey = entity.getConfigkey();
        if (configkey != null) {
            stmt.bindString(10, configkey);
        }
 
        String plan_id = entity.getPlan_id();
        if (plan_id != null) {
            stmt.bindString(11, plan_id);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, RepairSysDeviceSetting entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
        stmt.bindLong(2, entity.getInput_type());
 
        String cnname = entity.getCnname();
        if (cnname != null) {
            stmt.bindString(3, cnname);
        }
 
        String enname = entity.getEnname();
        if (enname != null) {
            stmt.bindString(4, enname);
        }
        stmt.bindLong(5, entity.getPara_type());
        stmt.bindLong(6, entity.getIsphoto());
        stmt.bindLong(7, entity.getPara_max());
        stmt.bindLong(8, entity.getPara_min());
        stmt.bindLong(9, entity.getIsrange());
 
        String configkey = entity.getConfigkey();
        if (configkey != null) {
            stmt.bindString(10, configkey);
        }
 
        String plan_id = entity.getPlan_id();
        if (plan_id != null) {
            stmt.bindString(11, plan_id);
        }
    }

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

    @Override
    public RepairSysDeviceSetting readEntity(Cursor cursor, int offset) {
        RepairSysDeviceSetting entity = new RepairSysDeviceSetting( //
            cursor.getString(offset + 0), // id
            cursor.getInt(offset + 1), // input_type
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // cnname
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // enname
            cursor.getInt(offset + 4), // para_type
            cursor.getInt(offset + 5), // isphoto
            cursor.getInt(offset + 6), // para_max
            cursor.getInt(offset + 7), // para_min
            cursor.getInt(offset + 8), // isrange
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // configkey
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // plan_id
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, RepairSysDeviceSetting entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setInput_type(cursor.getInt(offset + 1));
        entity.setCnname(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setEnname(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setPara_type(cursor.getInt(offset + 4));
        entity.setIsphoto(cursor.getInt(offset + 5));
        entity.setPara_max(cursor.getInt(offset + 6));
        entity.setPara_min(cursor.getInt(offset + 7));
        entity.setIsrange(cursor.getInt(offset + 8));
        entity.setConfigkey(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setPlan_id(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
     }
    
    @Override
    protected final String updateKeyAfterInsert(RepairSysDeviceSetting entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(RepairSysDeviceSetting entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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