package com.casic.br.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.br.model.LocaleMessageBean;

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

    public static final String TABLENAME = "LOCALE_MESSAGE_BEAN";

    /**
     * Properties of entity LocaleMessageBean.<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 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 MessageTime = new Property(5, String.class, "messageTime", false, "MESSAGE_TIME");
        public final static Property IsRead = new Property(6, String.class, "isRead", false, "IS_READ");
    }


    public LocaleMessageBeanDao(DaoConfig config) {
        super(config);
    }
    
    public LocaleMessageBeanDao(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 + "\"LOCALE_MESSAGE_BEAN\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"MESSAGE_ID\" TEXT UNIQUE ," + // 1: messageId
                "\"USER_ID\" TEXT," + // 2: userId
                "\"TITLE\" TEXT," + // 3: title
                "\"CONTENT\" TEXT," + // 4: content
                "\"MESSAGE_TIME\" TEXT," + // 5: messageTime
                "\"IS_READ\" TEXT);"); // 6: isRead
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, LocaleMessageBean 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 title = entity.getTitle();
        if (title != null) {
            stmt.bindString(4, title);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(5, content);
        }
 
        String messageTime = entity.getMessageTime();
        if (messageTime != null) {
            stmt.bindString(6, messageTime);
        }
 
        String isRead = entity.getIsRead();
        if (isRead != null) {
            stmt.bindString(7, isRead);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, LocaleMessageBean 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 title = entity.getTitle();
        if (title != null) {
            stmt.bindString(4, title);
        }
 
        String content = entity.getContent();
        if (content != null) {
            stmt.bindString(5, content);
        }
 
        String messageTime = entity.getMessageTime();
        if (messageTime != null) {
            stmt.bindString(6, messageTime);
        }
 
        String isRead = entity.getIsRead();
        if (isRead != null) {
            stmt.bindString(7, isRead);
        }
    }

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

    @Override
    public LocaleMessageBean readEntity(Cursor cursor, int offset) {
        LocaleMessageBean entity = new LocaleMessageBean( //
            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), // title
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // content
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // messageTime
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // isRead
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, LocaleMessageBean 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.setTitle(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setContent(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setMessageTime(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setIsRead(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(LocaleMessageBean entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(LocaleMessageBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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