package com.hippo.ehviewer.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;

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

    public static final String TABLENAME = "Black_List";

    /**
     * Properties of entity BlackList.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Id = new Property(0, Long.class, "id", true, "_id");
        public final static Property Badgayname = new Property(1, String.class, "badgayname", false, "BADGAYNAME");
        public final static Property Reason = new Property(2, String.class, "reason", false, "REASON");
        public final static Property Angrywith = new Property(3, String.class, "angrywith", false, "ANGRYWITH");
        public final static Property Add_time = new Property(4, String.class, "add_time", false, "ADD_TIME");
        public final static Property Mode = new Property(5, Integer.class, "mode", false, "MODE");
    };


    public BlackListDao(DaoConfig config) {
        super(config);
    }
    
    public BlackListDao(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 + "\"Black_List\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"BADGAYNAME\" TEXT," + // 1: badgayname
                "\"REASON\" TEXT," + // 2: reason
                "\"ANGRYWITH\" TEXT," + // 3: angrywith
                "\"ADD_TIME\" TEXT," + // 4: add_time
                "\"MODE\" INTEGER);"); // 5: mode
        // Add Indexes
        db.execSQL("CREATE INDEX " + constraint + "IDX_Black_List_BADGAYNAME ON Black_List" +
                " (\"BADGAYNAME\");");
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BlackList entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String badgayname = entity.getBadgayname();
        if (badgayname != null) {
            stmt.bindString(2, badgayname);
        }
 
        String reason = entity.getReason();
        if (reason != null) {
            stmt.bindString(3, reason);
        }
 
        String angrywith = entity.getAngrywith();
        if (angrywith != null) {
            stmt.bindString(4, angrywith);
        }
 
        String add_time = entity.getAdd_time();
        if (add_time != null) {
            stmt.bindString(5, add_time);
        }
 
        Integer mode = entity.getMode();
        if (mode != null) {
            stmt.bindLong(6, mode);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BlackList entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String badgayname = entity.getBadgayname();
        if (badgayname != null) {
            stmt.bindString(2, badgayname);
        }
 
        String reason = entity.getReason();
        if (reason != null) {
            stmt.bindString(3, reason);
        }
 
        String angrywith = entity.getAngrywith();
        if (angrywith != null) {
            stmt.bindString(4, angrywith);
        }
 
        String add_time = entity.getAdd_time();
        if (add_time != null) {
            stmt.bindString(5, add_time);
        }
 
        Integer mode = entity.getMode();
        if (mode != null) {
            stmt.bindLong(6, mode);
        }
    }

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

    @Override
    public BlackList readEntity(Cursor cursor, int offset) {
        BlackList entity = new BlackList( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // badgayname
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // reason
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // angrywith
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // add_time
            cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5) // mode
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BlackList entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setBadgayname(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setReason(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setAngrywith(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setAdd_time(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setMode(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(BlackList entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(BlackList entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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