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.NoticeLocaleBean;

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

    public static final String TABLENAME = "NOTICE_LOCALE_BEAN";

    /**
     * Properties of entity NoticeLocaleBean.<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 MessageId = new Property(1, String.class, "messageId", false, "MESSAGE_ID");
        public final static Property UserId = new Property(2, String.class, "userId", false, "USER_ID");
        public final static Property UserAccount = new Property(3, String.class, "userAccount", false, "USER_ACCOUNT");
        public final static Property CasePrimaryKey = new Property(4, String.class, "casePrimaryKey", false, "CASE_PRIMARY_KEY");
        public final static Property Title = new Property(5, String.class, "title", false, "TITLE");
        public final static Property Content = new Property(6, String.class, "content", false, "CONTENT");
        public final static Property PushDate = new Property(7, String.class, "pushDate", false, "PUSH_DATE");
        public final static Property IsRead = new Property(8, String.class, "isRead", false, "IS_READ");
    }


    public NoticeLocaleBeanDao(DaoConfig config) {
        super(config);
    }
    
    public NoticeLocaleBeanDao(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_LOCALE_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId
                "\"USER_ID\" TEXT," + // 2: userId
                "\"USER_ACCOUNT\" TEXT," + // 3: userAccount
                "\"CASE_PRIMARY_KEY\" TEXT," + // 4: casePrimaryKey
                "\"TITLE\" TEXT," + // 5: title
                "\"CONTENT\" TEXT," + // 6: content
                "\"PUSH_DATE\" TEXT," + // 7: pushDate
                "\"IS_READ\" TEXT);"); // 8: isRead
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, NoticeLocaleBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String messageId = entity.getMessageId();
        if (messageId != null) {
            stmt.bindString(2, messageId);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(3, userId);
        }
 
        String userAccount = entity.getUserAccount();
        if (userAccount != null) {
            stmt.bindString(4, userAccount);
        }
 
        String casePrimaryKey = entity.getCasePrimaryKey();
        if (casePrimaryKey != null) {
            stmt.bindString(5, casePrimaryKey);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(6, title);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(7, content);
        }
 
        String pushDate = entity.getPushDate();
        if (pushDate != null) {
            stmt.bindString(8, pushDate);
        }
 
        String isRead = entity.getIsRead();
        if (isRead != null) {
            stmt.bindString(9, isRead);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, NoticeLocaleBean entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String messageId = entity.getMessageId();
        if (messageId != null) {
            stmt.bindString(2, messageId);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(3, userId);
        }
 
        String userAccount = entity.getUserAccount();
        if (userAccount != null) {
            stmt.bindString(4, userAccount);
        }
 
        String casePrimaryKey = entity.getCasePrimaryKey();
        if (casePrimaryKey != null) {
            stmt.bindString(5, casePrimaryKey);
        }
 
        String title = entity.getTitle();
        if (title != null) {
            stmt.bindString(6, title);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(7, content);
        }
 
        String pushDate = entity.getPushDate();
        if (pushDate != null) {
            stmt.bindString(8, pushDate);
        }
 
        String isRead = entity.getIsRead();
        if (isRead != null) {
            stmt.bindString(9, isRead);
        }
    }

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

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

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

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