package org.zarroboogs.weibo.greendao.dao;

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

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

import org.zarroboogs.weibo.greendao.bean.Green_AccountBean;

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

/**
 * DAO for table "account_table".
 */
public class Green_AccountBeanDao extends AbstractDao<Green_AccountBean, Long> {

    public static final String TABLENAME = "account_table";

    /**
     * Properties of entity Green_AccountBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Uid = new Property(0, Long.class, "uid", true, "UID");
        public final static Property User_name = new Property(1, String.class, "user_name", false, "USER_NAME");
        public final static Property User_password = new Property(2, String.class, "user_password", false, "USER_PASSWORD");
        public final static Property Cookie = new Property(3, String.class, "cookie", false, "COOKIE");
        public final static Property Oauth_token = new Property(4, String.class, "oauth_token", false, "OAUTH_TOKEN");
        public final static Property Oauth_token_expires_time = new Property(5, Long.class, "oauth_token_expires_time", false, "OAUTH_TOKEN_EXPIRES_TIME");
        public final static Property Access_token_hack = new Property(6, String.class, "access_token_hack", false, "ACCESS_TOKEN_HACK");
        public final static Property Expires_time_hack = new Property(7, Long.class, "expires_time_hack", false, "EXPIRES_TIME_HACK");
        public final static Property G_sid = new Property(8, String.class, "g_sid", false, "G_SID");
        public final static Property Navigation_position = new Property(9, Integer.class, "navigation_position", false, "NAVIGATION_POSITION");
        public final static Property User_info_json = new Property(10, String.class, "user_info_json", false, "USER_INFO_JSON");
    }


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

    public Green_AccountBeanDao(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 + "\"account_table\" (" + //
                "\"UID\" INTEGER PRIMARY KEY ," + // 0: uid
                "\"USER_NAME\" TEXT," + // 1: user_name
                "\"USER_PASSWORD\" TEXT," + // 2: user_password
                "\"COOKIE\" TEXT," + // 3: cookie
                "\"OAUTH_TOKEN\" TEXT," + // 4: oauth_token
                "\"OAUTH_TOKEN_EXPIRES_TIME\" INTEGER," + // 5: oauth_token_expires_time
                "\"ACCESS_TOKEN_HACK\" TEXT," + // 6: access_token_hack
                "\"EXPIRES_TIME_HACK\" INTEGER," + // 7: expires_time_hack
                "\"G_SID\" TEXT," + // 8: g_sid
                "\"NAVIGATION_POSITION\" INTEGER," + // 9: navigation_position
                "\"USER_INFO_JSON\" TEXT);"); // 10: user_info_json
    }

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

    /**
     * @inheritdoc
     */
    @Override
    protected void bindValues(SQLiteStatement stmt, Green_AccountBean entity) {
        stmt.clearBindings();

        Long uid = entity.getUid();
        if (uid != null) {
            stmt.bindLong(1, uid);
        }

        String user_name = entity.getUser_name();
        if (user_name != null) {
            stmt.bindString(2, user_name);
        }

        String user_password = entity.getUser_password();
        if (user_password != null) {
            stmt.bindString(3, user_password);
        }

        String cookie = entity.getCookie();
        if (cookie != null) {
            stmt.bindString(4, cookie);
        }

        String oauth_token = entity.getOauth_token();
        if (oauth_token != null) {
            stmt.bindString(5, oauth_token);
        }

        Long oauth_token_expires_time = entity.getOauth_token_expires_time();
        if (oauth_token_expires_time != null) {
            stmt.bindLong(6, oauth_token_expires_time);
        }

        String access_token_hack = entity.getAccess_token_hack();
        if (access_token_hack != null) {
            stmt.bindString(7, access_token_hack);
        }

        Long expires_time_hack = entity.getExpires_time_hack();
        if (expires_time_hack != null) {
            stmt.bindLong(8, expires_time_hack);
        }

        String g_sid = entity.getG_sid();
        if (g_sid != null) {
            stmt.bindString(9, g_sid);
        }

        Integer navigation_position = entity.getNavigation_position();
        if (navigation_position != null) {
            stmt.bindLong(10, navigation_position);
        }

        String user_info_json = entity.getUser_info_json();
        if (user_info_json != null) {
            stmt.bindString(11, user_info_json);
        }
    }

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

    /**
     * @inheritdoc
     */
    @Override
    public Green_AccountBean readEntity(Cursor cursor, int offset) {
        Green_AccountBean entity = new Green_AccountBean( //
                cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // uid
                cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // user_name
                cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // user_password
                cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // cookie
                cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // oauth_token
                cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5), // oauth_token_expires_time
                cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // access_token_hack
                cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7), // expires_time_hack
                cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // g_sid
                cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // navigation_position
                cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10) // user_info_json
        );
        return entity;
    }

    /**
     * @inheritdoc
     */
    @Override
    public void readEntity(Cursor cursor, Green_AccountBean entity, int offset) {
        entity.setUid(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setUser_name(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setUser_password(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCookie(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setOauth_token(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setOauth_token_expires_time(cursor.isNull(offset + 5) ? null : cursor.getLong(offset + 5));
        entity.setAccess_token_hack(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setExpires_time_hack(cursor.isNull(offset + 7) ? null : cursor.getLong(offset + 7));
        entity.setG_sid(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setNavigation_position(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
        entity.setUser_info_json(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
    }

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

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

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

}
