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.notifyManage.NotifyManageBean;

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

    public static final String TABLENAME = "DB_NOTIFY_MANAGE_BEAN";

    /**
     * Properties of entity NotifyManageBean.<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 ServerId = new Property(1, String.class, "serverId", false, "SERVER_ID");
        public final static Property Userid = new Property(2, String.class, "userid", false, "USERID");
        public final static Property Notify_type = new Property(3, int.class, "notify_type", false, "NOTIFY_TYPE");
        public final static Property IsNotify = new Property(4, boolean.class, "isNotify", false, "IS_NOTIFY");
        public final static Property IsRead = new Property(5, boolean.class, "isRead", false, "IS_READ");
    }


    public NotifyManageBeanDao(DaoConfig config) {
        super(config);
    }
    
    public NotifyManageBeanDao(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_NOTIFY_MANAGE_BEAN\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"SERVER_ID\" TEXT," + // 1: serverId
                "\"USERID\" TEXT," + // 2: userid
                "\"NOTIFY_TYPE\" INTEGER NOT NULL ," + // 3: notify_type
                "\"IS_NOTIFY\" INTEGER NOT NULL ," + // 4: isNotify
                "\"IS_READ\" INTEGER NOT NULL );"); // 5: isRead
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, NotifyManageBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String serverId = entity.getServerId();
        if (serverId != null) {
            stmt.bindString(2, serverId);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(3, userid);
        }
        stmt.bindLong(4, entity.getNotify_type());
        stmt.bindLong(5, entity.getIsNotify() ? 1L: 0L);
        stmt.bindLong(6, entity.getIsRead() ? 1L: 0L);
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, NotifyManageBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String serverId = entity.getServerId();
        if (serverId != null) {
            stmt.bindString(2, serverId);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(3, userid);
        }
        stmt.bindLong(4, entity.getNotify_type());
        stmt.bindLong(5, entity.getIsNotify() ? 1L: 0L);
        stmt.bindLong(6, entity.getIsRead() ? 1L: 0L);
    }

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

    @Override
    public NotifyManageBean readEntity(Cursor cursor, int offset) {
        NotifyManageBean entity = new NotifyManageBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // serverId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // userid
            cursor.getInt(offset + 3), // notify_type
            cursor.getShort(offset + 4) != 0, // isNotify
            cursor.getShort(offset + 5) != 0 // isRead
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, NotifyManageBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setServerId(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setUserid(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setNotify_type(cursor.getInt(offset + 3));
        entity.setIsNotify(cursor.getShort(offset + 4) != 0);
        entity.setIsRead(cursor.getShort(offset + 5) != 0);
     }
    
    @Override
    protected final String updateKeyAfterInsert(NotifyManageBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(NotifyManageBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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