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.buildManage.domain.BuildSignDataBean;

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

    public static final String TABLENAME = "DB_BUILD_SIGN";

    /**
     * Properties of entity BuildSignDataBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property PlanState = new Property(0, int.class, "planState", false, "PLAN_STATE");
        public final static Property HasPlan = new Property(1, int.class, "hasPlan", false, "HAS_PLAN");
        public final static Property PlanDate = new Property(2, String.class, "planDate", true, "PLAN_DATE");
    }


    public BuildSignDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildSignDataBeanDao(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_BUILD_SIGN\" (" + //
                "\"PLAN_STATE\" INTEGER NOT NULL ," + // 0: planState
                "\"HAS_PLAN\" INTEGER NOT NULL ," + // 1: hasPlan
                "\"PLAN_DATE\" TEXT PRIMARY KEY NOT NULL UNIQUE );"); // 2: planDate
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildSignDataBean entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getPlanState());
        stmt.bindLong(2, entity.getHasPlan());
        stmt.bindString(3, entity.getPlanDate());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildSignDataBean entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getPlanState());
        stmt.bindLong(2, entity.getHasPlan());
        stmt.bindString(3, entity.getPlanDate());
    }

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

    @Override
    public BuildSignDataBean readEntity(Cursor cursor, int offset) {
        BuildSignDataBean entity = new BuildSignDataBean( //
            cursor.getInt(offset + 0), // planState
            cursor.getInt(offset + 1), // hasPlan
            cursor.getString(offset + 2) // planDate
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildSignDataBean entity, int offset) {
        entity.setPlanState(cursor.getInt(offset + 0));
        entity.setHasPlan(cursor.getInt(offset + 1));
        entity.setPlanDate(cursor.getString(offset + 2));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildSignDataBean entity, long rowId) {
        return entity.getPlanDate();
    }
    
    @Override
    public String getKey(BuildSignDataBean entity) {
        if(entity != null) {
            return entity.getPlanDate();
        } else {
            return null;
        }
    }

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

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