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 "Gallery_Tags".
*/
public class GalleryTagsDao extends AbstractDao<GalleryTags, Long> {

    public static final String TABLENAME = "Gallery_Tags";

    /**
     * Properties of entity GalleryTags.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Gid = new Property(0, long.class, "gid", true, "GID");
        public final static Property Rows = new Property(1, String.class, "rows", false, "ROWS");
        public final static Property Artist = new Property(2, String.class, "artist", false, "ARTIST");
        public final static Property Cosplayer = new Property(3, String.class, "cosplayer", false, "COSPLAYER");
        public final static Property Character = new Property(4, String.class, "character", false, "CHARACTER");
        public final static Property Female = new Property(5, String.class, "female", false, "FEMALE");
        public final static Property Group = new Property(6, String.class, "group", false, "GROUP");
        public final static Property Language = new Property(7, String.class, "language", false, "LANGUAGE");
        public final static Property Male = new Property(8, String.class, "male", false, "MALE");
        public final static Property Misc = new Property(9, String.class, "misc", false, "MISC");
        public final static Property Mixed = new Property(10, String.class, "mixed", false, "MIXED");
        public final static Property Other = new Property(11, String.class, "other", false, "OTHER");
        public final static Property Parody = new Property(12, String.class, "parody", false, "PARODY");
        public final static Property Reclass = new Property(13, String.class, "reclass", false, "RECLASS");
        public final static Property Create_time = new Property(14, java.util.Date.class, "create_time", false, "CREATE_TIME");
        public final static Property Update_time = new Property(15, java.util.Date.class, "update_time", false, "UPDATE_TIME");
    };


    public GalleryTagsDao(DaoConfig config) {
        super(config);
    }
    
    public GalleryTagsDao(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 + "\"Gallery_Tags\" (" + //
                "\"GID\" INTEGER PRIMARY KEY NOT NULL ," + // 0: gid
                "\"ROWS\" TEXT," + // 1: rows
                "\"ARTIST\" TEXT," + // 2: artist
                "\"COSPLAYER\" TEXT," + // 3: cosplayer
                "\"CHARACTER\" TEXT," + // 4: character
                "\"FEMALE\" TEXT," + // 5: female
                "\"GROUP\" TEXT," + // 6: group
                "\"LANGUAGE\" TEXT," + // 7: language
                "\"MALE\" TEXT," + // 8: male
                "\"MISC\" TEXT," + // 9: misc
                "\"MIXED\" TEXT," + // 10: mixed
                "\"OTHER\" TEXT," + // 11: other
                "\"PARODY\" TEXT," + // 12: parody
                "\"RECLASS\" TEXT," + // 13: reclass
                "\"CREATE_TIME\" INTEGER," + // 14: create_time
                "\"UPDATE_TIME\" INTEGER);"); // 15: update_time
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, GalleryTags entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getGid());
 
        String rows = entity.getRows();
        if (rows != null) {
            stmt.bindString(2, rows);
        }
 
        String artist = entity.getArtist();
        if (artist != null) {
            stmt.bindString(3, artist);
        }
 
        String cosplayer = entity.getCosplayer();
        if (cosplayer != null) {
            stmt.bindString(4, cosplayer);
        }
 
        String character = entity.getCharacter();
        if (character != null) {
            stmt.bindString(5, character);
        }
 
        String female = entity.getFemale();
        if (female != null) {
            stmt.bindString(6, female);
        }
 
        String group = entity.getGroup();
        if (group != null) {
            stmt.bindString(7, group);
        }
 
        String language = entity.getLanguage();
        if (language != null) {
            stmt.bindString(8, language);
        }
 
        String male = entity.getMale();
        if (male != null) {
            stmt.bindString(9, male);
        }
 
        String misc = entity.getMisc();
        if (misc != null) {
            stmt.bindString(10, misc);
        }
 
        String mixed = entity.getMixed();
        if (mixed != null) {
            stmt.bindString(11, mixed);
        }
 
        String other = entity.getOther();
        if (other != null) {
            stmt.bindString(12, other);
        }
 
        String parody = entity.getParody();
        if (parody != null) {
            stmt.bindString(13, parody);
        }
 
        String reclass = entity.getReclass();
        if (reclass != null) {
            stmt.bindString(14, reclass);
        }
 
        java.util.Date create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindLong(15, create_time.getTime());
        }
 
        java.util.Date update_time = entity.getUpdate_time();
        if (update_time != null) {
            stmt.bindLong(16, update_time.getTime());
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, GalleryTags entity) {
        stmt.clearBindings();
        stmt.bindLong(1, entity.getGid());
 
        String rows = entity.getRows();
        if (rows != null) {
            stmt.bindString(2, rows);
        }
 
        String artist = entity.getArtist();
        if (artist != null) {
            stmt.bindString(3, artist);
        }
 
        String cosplayer = entity.getCosplayer();
        if (cosplayer != null) {
            stmt.bindString(4, cosplayer);
        }
 
        String character = entity.getCharacter();
        if (character != null) {
            stmt.bindString(5, character);
        }
 
        String female = entity.getFemale();
        if (female != null) {
            stmt.bindString(6, female);
        }
 
        String group = entity.getGroup();
        if (group != null) {
            stmt.bindString(7, group);
        }
 
        String language = entity.getLanguage();
        if (language != null) {
            stmt.bindString(8, language);
        }
 
        String male = entity.getMale();
        if (male != null) {
            stmt.bindString(9, male);
        }
 
        String misc = entity.getMisc();
        if (misc != null) {
            stmt.bindString(10, misc);
        }
 
        String mixed = entity.getMixed();
        if (mixed != null) {
            stmt.bindString(11, mixed);
        }
 
        String other = entity.getOther();
        if (other != null) {
            stmt.bindString(12, other);
        }
 
        String parody = entity.getParody();
        if (parody != null) {
            stmt.bindString(13, parody);
        }
 
        String reclass = entity.getReclass();
        if (reclass != null) {
            stmt.bindString(14, reclass);
        }
 
        java.util.Date create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindLong(15, create_time.getTime());
        }
 
        java.util.Date update_time = entity.getUpdate_time();
        if (update_time != null) {
            stmt.bindLong(16, update_time.getTime());
        }
    }

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

    @Override
    public GalleryTags readEntity(Cursor cursor, int offset) {
        GalleryTags entity = new GalleryTags( //
            cursor.getLong(offset + 0), // gid
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // rows
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // artist
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // cosplayer
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // character
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // female
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // group
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // language
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // male
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // misc
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // mixed
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // other
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // parody
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // reclass
            cursor.isNull(offset + 14) ? null : new java.util.Date(cursor.getLong(offset + 14)), // create_time
            cursor.isNull(offset + 15) ? null : new java.util.Date(cursor.getLong(offset + 15)) // update_time
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, GalleryTags entity, int offset) {
        entity.setGid(cursor.getLong(offset + 0));
        entity.setRows(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setArtist(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCosplayer(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCharacter(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setFemale(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setGroup(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setLanguage(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setMale(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setMisc(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setMixed(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setOther(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setParody(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setReclass(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setCreate_time(cursor.isNull(offset + 14) ? null : new java.util.Date(cursor.getLong(offset + 14)));
        entity.setUpdate_time(cursor.isNull(offset + 15) ? null : new java.util.Date(cursor.getLong(offset + 15)));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(GalleryTags entity, long rowId) {
        entity.setGid(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(GalleryTags entity) {
        if(entity != null) {
            return entity.getGid();
        } else {
            return null;
        }
    }

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