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 "QUICK_SEARCH".
*/
public class QuickSearchDao extends AbstractDao<QuickSearch, Long> {

    public static final String TABLENAME = "QUICK_SEARCH";

    /**
     * Properties of entity QuickSearch.<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 Name = new Property(1, String.class, "name", false, "NAME");
        public final static Property Mode = new Property(2, int.class, "mode", false, "MODE");
        public final static Property Category = new Property(3, int.class, "category", false, "CATEGORY");
        public final static Property Keyword = new Property(4, String.class, "keyword", false, "KEYWORD");
        public final static Property AdvanceSearch = new Property(5, int.class, "advanceSearch", false, "ADVANCE_SEARCH");
        public final static Property MinRating = new Property(6, int.class, "minRating", false, "MIN_RATING");
        public final static Property PageFrom = new Property(7, int.class, "pageFrom", false, "PAGE_FROM");
        public final static Property PageTo = new Property(8, int.class, "pageTo", false, "PAGE_TO");
        public final static Property Time = new Property(9, long.class, "time", false, "TIME");
    };


    public QuickSearchDao(DaoConfig config) {
        super(config);
    }
    
    public QuickSearchDao(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 + "\"QUICK_SEARCH\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: id
                "\"NAME\" TEXT," + // 1: name
                "\"MODE\" INTEGER NOT NULL ," + // 2: mode
                "\"CATEGORY\" INTEGER NOT NULL ," + // 3: category
                "\"KEYWORD\" TEXT," + // 4: keyword
                "\"ADVANCE_SEARCH\" INTEGER NOT NULL ," + // 5: advanceSearch
                "\"MIN_RATING\" INTEGER NOT NULL ," + // 6: minRating
                "\"PAGE_FROM\" INTEGER NOT NULL ," + // 7: pageFrom
                "\"PAGE_TO\" INTEGER NOT NULL ," + // 8: pageTo
                "\"TIME\" INTEGER NOT NULL );"); // 9: time
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, QuickSearch entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
        stmt.bindLong(3, entity.getMode());
        stmt.bindLong(4, entity.getCategory());
 
        String keyword = entity.getKeyword();
        if (keyword != null) {
            stmt.bindString(5, keyword);
        }
        stmt.bindLong(6, entity.getAdvanceSearch());
        stmt.bindLong(7, entity.getMinRating());
        stmt.bindLong(8, entity.getPageFrom());
        stmt.bindLong(9, entity.getPageTo());
        stmt.bindLong(10, entity.getTime());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, QuickSearch entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(2, name);
        }
        stmt.bindLong(3, entity.getMode());
        stmt.bindLong(4, entity.getCategory());
 
        String keyword = entity.getKeyword();
        if (keyword != null) {
            stmt.bindString(5, keyword);
        }
        stmt.bindLong(6, entity.getAdvanceSearch());
        stmt.bindLong(7, entity.getMinRating());
        stmt.bindLong(8, entity.getPageFrom());
        stmt.bindLong(9, entity.getPageTo());
        stmt.bindLong(10, entity.getTime());
    }

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

    @Override
    public QuickSearch readEntity(Cursor cursor, int offset) {
        QuickSearch entity = new QuickSearch( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
            cursor.getInt(offset + 2), // mode
            cursor.getInt(offset + 3), // category
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // keyword
            cursor.getInt(offset + 5), // advanceSearch
            cursor.getInt(offset + 6), // minRating
            cursor.getInt(offset + 7), // pageFrom
            cursor.getInt(offset + 8), // pageTo
            cursor.getLong(offset + 9) // time
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, QuickSearch entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setMode(cursor.getInt(offset + 2));
        entity.setCategory(cursor.getInt(offset + 3));
        entity.setKeyword(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setAdvanceSearch(cursor.getInt(offset + 5));
        entity.setMinRating(cursor.getInt(offset + 6));
        entity.setPageFrom(cursor.getInt(offset + 7));
        entity.setPageTo(cursor.getInt(offset + 8));
        entity.setTime(cursor.getLong(offset + 9));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(QuickSearch entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(QuickSearch entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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