package com.d.music.data.database.greendao.dao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

import com.d.music.data.database.greendao.bean.CustomListModel;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * DAO for table "CUSTOM_LIST_MODEL".
 */
public class CustomListModelDao extends AbstractDao<CustomListModel, Long> {

    public static final String TABLENAME = "CUSTOM_LIST_MODEL";

    public CustomListModelDao(DaoConfig config) {
        super(config);
    }

    ;


    public CustomListModelDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /**
     * Creates the underlying database table.
     */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists ? "IF NOT EXISTS " : "";
        db.execSQL("CREATE TABLE " + constraint + "\"CUSTOM_LIST_MODEL\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"NAME\" TEXT," + // 1: name
                "\"COUNT\" INTEGER," + // 2: count
                "\"SEQ\" INTEGER," + // 3: seq
                "\"SORT_TYPE\" INTEGER," + // 4: sortType
                "\"POINTER\" INTEGER);"); // 5: pointer
    }

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

    /**
     * @inheritdoc
     */
    @Override
    protected void bindValues(SQLiteStatement stmt, CustomListModel 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);
        }

        Long count = entity.getCount();
        if (count != null) {
            stmt.bindLong(3, count);
        }

        Integer seq = entity.getSeq();
        if (seq != null) {
            stmt.bindLong(4, seq);
        }

        Integer sortType = entity.getSortType();
        if (sortType != null) {
            stmt.bindLong(5, sortType);
        }

        Integer pointer = entity.getPointer();
        if (pointer != null) {
            stmt.bindLong(6, pointer);
        }
    }

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

    /**
     * @inheritdoc
     */
    @Override
    public CustomListModel readEntity(Cursor cursor, int offset) {
        CustomListModel entity = new CustomListModel( //
                cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
                cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // name
                cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2), // count
                cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3), // seq
                cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4), // sortType
                cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5) // pointer
        );
        return entity;
    }

    /**
     * @inheritdoc
     */
    @Override
    public void readEntity(Cursor cursor, CustomListModel 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.setCount(cursor.isNull(offset + 2) ? null : cursor.getLong(offset + 2));
        entity.setSeq(cursor.isNull(offset + 3) ? null : cursor.getInt(offset + 3));
        entity.setSortType(cursor.isNull(offset + 4) ? null : cursor.getInt(offset + 4));
        entity.setPointer(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
    }

    /**
     * @inheritdoc
     */
    @Override
    protected Long updateKeyAfterInsert(CustomListModel entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }

    /**
     * @inheritdoc
     */
    @Override
    public Long getKey(CustomListModel entity) {
        if (entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    /**
     * @inheritdoc
     */
    @Override
    protected boolean isEntityUpdateable() {
        return true;
    }

    /**
     * Properties of entity CustomListModel.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public static final Property Id = new Property(0, Long.class, "id", true, "_id");
        public static final Property Name = new Property(1, String.class, "name", false, "NAME");
        public static final Property Count = new Property(2, Long.class, "count", false, "COUNT");
        public static final Property Seq = new Property(3, Integer.class, "seq", false, "SEQ");
        public static final Property SortType = new Property(4, Integer.class, "sortType", false, "SORT_TYPE");
        public static final Property Pointer = new Property(5, Integer.class, "pointer", false, "POINTER");
    }

}
