package com.casic.dcms.greendao;

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.casic.dcms.bean.NoticeBean;

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

    public static final String TABLENAME = "NOTICE_BEAN";

    /**
     * Properties of entity NoticeBean.<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 UserAccount = new Property(1, String.class, "userAccount", false, "USER_ACCOUNT");
        public final static Property CaseId = new Property(2, String.class, "caseId", false, "CASE_ID");
        public final static Property Title = new Property(3, String.class, "title", false, "TITLE");
        public final static Property Content = new Property(4, String.class, "content", false, "CONTENT");
        public final static Property PushDate = new Property(5, String.class, "pushDate", false, "PUSH_DATE");
        public final static Property Type = new Property(6, String.class, "type", false, "TYPE");
        public final static Property IsRead = new Property(7, String.class, "isRead", false, "IS_READ");
    }


    public NoticeBeanDao(DaoConfig config) {
        super(config);
    }
    
    public NoticeBeanDao(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 + "\"NOTICE_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"USER_ACCOUNT\" TEXT," + // 1: userAccount
                "\"CASE_ID\" TEXT," + // 2: caseId
                "\"TITLE\" TEXT," + // 3: title
                "\"CONTENT\" TEXT," + // 4: content
                "\"PUSH_DATE\" TEXT," + // 5: pushDate
                "\"TYPE\" TEXT," + // 6: type
                "\"IS_READ\" TEXT);"); // 7: isRead
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, NoticeBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String userAccount = entity.getUserAccount();
        if (userAccount != null) {
            stmt.bindString(2, userAccount);
        }
 
        String caseId = entity.getCaseId();
        if (caseId != null) {
            stmt.bindString(3, caseId);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(4, title);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(5, content);
        }
 
        String pushDate = entity.getPushDate();
        if (pushDate != null) {
            stmt.bindString(6, pushDate);
        }
 
        String type = entity.getType();
        if (type != null) {
            stmt.bindString(7, type);
        }
 
        String isRead = entity.getIsRead();
        if (isRead != null) {
            stmt.bindString(8, isRead);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, NoticeBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String userAccount = entity.getUserAccount();
        if (userAccount != null) {
            stmt.bindString(2, userAccount);
        }
 
        String caseId = entity.getCaseId();
        if (caseId != null) {
            stmt.bindString(3, caseId);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(4, title);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(5, content);
        }
 
        String pushDate = entity.getPushDate();
        if (pushDate != null) {
            stmt.bindString(6, pushDate);
        }
 
        String type = entity.getType();
        if (type != null) {
            stmt.bindString(7, type);
        }
 
        String isRead = entity.getIsRead();
        if (isRead != null) {
            stmt.bindString(8, isRead);
        }
    }

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

    @Override
    public NoticeBean readEntity(Cursor cursor, int offset) {
        NoticeBean entity = new NoticeBean( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // userAccount
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // caseId
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // title
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // pushDate
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // type
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7) // isRead
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, NoticeBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setUserAccount(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setCaseId(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setPushDate(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setType(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setIsRead(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(NoticeBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(NoticeBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(NoticeBean entity) {
        return entity.getId() != null;
    }

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