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

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

    public static final String TABLENAME = "DB_SIGN";

    /**
     * Properties of entity SignDataBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property SignStatus = new Property(0, int.class, "signStatus", false, "SIGN_STATUS");
        public final static Property SignTime = new Property(1, String.class, "signTime", false, "SIGN_TIME");
        public final static Property SignAddr = new Property(2, String.class, "signAddr", false, "SIGN_ADDR");
        public final static Property PlanState = new Property(3, int.class, "planState", false, "PLAN_STATE");
        public final static Property HasPlan = new Property(4, int.class, "hasPlan", false, "HAS_PLAN");
        public final static Property PlanNum = new Property(5, int.class, "planNum", false, "PLAN_NUM");
        public final static Property CarPlanNum = new Property(6, int.class, "carPlanNum", false, "CAR_PLAN_NUM");
        public final static Property NeedUpdate = new Property(7, int.class, "needUpdate", false, "NEED_UPDATE");
        public final static Property CarNeedUpdate = new Property(8, int.class, "carNeedUpdate", false, "CAR_NEED_UPDATE");
        public final static Property PlanIds = new Property(9, String.class, "planIds", false, "PLAN_IDS");
        public final static Property PlanDate = new Property(10, String.class, "planDate", true, "PLAN_DATE");
    }


    public SignDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public SignDataBeanDao(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\" (" + //
                "\"SIGN_STATUS\" INTEGER NOT NULL ," + // 0: signStatus
                "\"SIGN_TIME\" TEXT," + // 1: signTime
                "\"SIGN_ADDR\" TEXT," + // 2: signAddr
                "\"PLAN_STATE\" INTEGER NOT NULL ," + // 3: planState
                "\"HAS_PLAN\" INTEGER NOT NULL ," + // 4: hasPlan
                "\"PLAN_NUM\" INTEGER NOT NULL ," + // 5: planNum
                "\"CAR_PLAN_NUM\" INTEGER NOT NULL ," + // 6: carPlanNum
                "\"NEED_UPDATE\" INTEGER NOT NULL ," + // 7: needUpdate
                "\"CAR_NEED_UPDATE\" INTEGER NOT NULL ," + // 8: carNeedUpdate
                "\"PLAN_IDS\" TEXT," + // 9: planIds
                "\"PLAN_DATE\" TEXT PRIMARY KEY NOT NULL UNIQUE );"); // 10: planDate
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, SignDataBean entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getSignStatus());
 
        String signTime = entity.getSignTime();
        if (signTime != null) {
            stmt.bindString(2, signTime);
        }
 
        String signAddr = entity.getSignAddr();
        if (signAddr != null) {
            stmt.bindString(3, signAddr);
        }
        stmt.bindLong(4, entity.getPlanState());
        stmt.bindLong(5, entity.getHasPlan());
        stmt.bindLong(6, entity.getPlanNum());
        stmt.bindLong(7, entity.getCarPlanNum());
        stmt.bindLong(8, entity.getNeedUpdate());
        stmt.bindLong(9, entity.getCarNeedUpdate());
 
        String planIds = entity.getPlanIds();
        if (planIds != null) {
            stmt.bindString(10, planIds);
        }
        stmt.bindString(11, entity.getPlanDate());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SignDataBean entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getSignStatus());
 
        String signTime = entity.getSignTime();
        if (signTime != null) {
            stmt.bindString(2, signTime);
        }
 
        String signAddr = entity.getSignAddr();
        if (signAddr != null) {
            stmt.bindString(3, signAddr);
        }
        stmt.bindLong(4, entity.getPlanState());
        stmt.bindLong(5, entity.getHasPlan());
        stmt.bindLong(6, entity.getPlanNum());
        stmt.bindLong(7, entity.getCarPlanNum());
        stmt.bindLong(8, entity.getNeedUpdate());
        stmt.bindLong(9, entity.getCarNeedUpdate());
 
        String planIds = entity.getPlanIds();
        if (planIds != null) {
            stmt.bindString(10, planIds);
        }
        stmt.bindString(11, entity.getPlanDate());
    }

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

    @Override
    public SignDataBean readEntity(Cursor cursor, int offset) {
        SignDataBean entity = new SignDataBean( //
            cursor.getInt(offset + 0), // signStatus
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // signTime
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // signAddr
            cursor.getInt(offset + 3), // planState
            cursor.getInt(offset + 4), // hasPlan
            cursor.getInt(offset + 5), // planNum
            cursor.getInt(offset + 6), // carPlanNum
            cursor.getInt(offset + 7), // needUpdate
            cursor.getInt(offset + 8), // carNeedUpdate
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // planIds
            cursor.getString(offset + 10) // planDate
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SignDataBean entity, int offset) {
        entity.setSignStatus(cursor.getInt(offset + 0));
        entity.setSignTime(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setSignAddr(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setPlanState(cursor.getInt(offset + 3));
        entity.setHasPlan(cursor.getInt(offset + 4));
        entity.setPlanNum(cursor.getInt(offset + 5));
        entity.setCarPlanNum(cursor.getInt(offset + 6));
        entity.setNeedUpdate(cursor.getInt(offset + 7));
        entity.setCarNeedUpdate(cursor.getInt(offset + 8));
        entity.setPlanIds(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setPlanDate(cursor.getString(offset + 10));
     }
    
    @Override
    protected final String updateKeyAfterInsert(SignDataBean entity, long rowId) {
        return entity.getPlanDate();
    }
    
    @Override
    public String getKey(SignDataBean entity) {
        if(entity != null) {
            return entity.getPlanDate();
        } else {
            return null;
        }
    }

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

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