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

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

    public static final String TABLENAME = "DB_BUILD_LOG_DATA";

    /**
     * Properties of entity BuildLogBean.<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 Build_id = new Property(1, String.class, "build_id", false, "BUILD_ID");
        public final static Property Time = new Property(2, String.class, "time", false, "TIME");
        public final static Property Open_state = new Property(3, int.class, "open_state", false, "OPEN_STATE");
        public final static Property State = new Property(4, int.class, "state", false, "STATE");
        public final static Property User_id = new Property(5, String.class, "user_id", false, "USER_ID");
    }


    public BuildLogBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildLogBeanDao(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_LOG_DATA\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"BUILD_ID\" TEXT," + // 1: build_id
                "\"TIME\" TEXT," + // 2: time
                "\"OPEN_STATE\" INTEGER NOT NULL ," + // 3: open_state
                "\"STATE\" INTEGER NOT NULL ," + // 4: state
                "\"USER_ID\" TEXT);"); // 5: user_id
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildLogBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String build_id = entity.getBuild_id();
        if (build_id != null) {
            stmt.bindString(2, build_id);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(3, time);
        }
        stmt.bindLong(4, entity.getOpen_state());
        stmt.bindLong(5, entity.getState());
 
        String user_id = entity.getUser_id();
        if (user_id != null) {
            stmt.bindString(6, user_id);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildLogBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String build_id = entity.getBuild_id();
        if (build_id != null) {
            stmt.bindString(2, build_id);
        }
 
        String time = entity.getTime();
        if (time != null) {
            stmt.bindString(3, time);
        }
        stmt.bindLong(4, entity.getOpen_state());
        stmt.bindLong(5, entity.getState());
 
        String user_id = entity.getUser_id();
        if (user_id != null) {
            stmt.bindString(6, user_id);
        }
    }

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

    @Override
    public BuildLogBean readEntity(Cursor cursor, int offset) {
        BuildLogBean entity = new BuildLogBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // build_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // time
            cursor.getInt(offset + 3), // open_state
            cursor.getInt(offset + 4), // state
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // user_id
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildLogBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setBuild_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setTime(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setOpen_state(cursor.getInt(offset + 3));
        entity.setState(cursor.getInt(offset + 4));
        entity.setUser_id(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildLogBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(BuildLogBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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