package com.kfzs.duanduan.data.graph.provider.player;

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.kfzs.duanduan.data.graph.provider.channel.DaoSession;

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

    public static final String TABLENAME = "USER";

    /**
     * Properties of entity User.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property MId = new Property(0, Long.class, "mId", true, "_id");
        public final static Property MUserId = new Property(1, String.class, "mUserId", false, "user_id");
        public final static Property MUserName = new Property(2, String.class, "mUserName", false, "user_name");
        public final static Property MUpdateTime = new Property(3, String.class, "mUpdateTime", false, "update_time");
        public final static Property MMobile = new Property(4, String.class, "mMobile", false, "mobile");
        public final static Property MNickName = new Property(5, String.class, "mNickName", false, "nick_name");
        public final static Property MUserIcon = new Property(6, String.class, "mUserIcon", false, "user_icon");
        public final static Property MAvatar = new Property(7, String.class, "mAvatar", false, "avatar");
        public final static Property MOpenId = new Property(8, String.class, "mOpenId", false, "open_id");
        public final static Property MEmail = new Property(9, String.class, "mEmail", false, "e_mail");
        public final static Property MToken = new Property(10, String.class, "mToken", false, "token");
        public final static Property MUserCard = new Property(11, String.class, "mUserCard", false, "user_card");
        public final static Property MIsBind = new Property(12, Integer.class, "mIsBind", false, "is_bind");
        public final static Property MIsCertification = new Property(13, Integer.class, "mIsCertification", false, "is_cer");
        public final static Property MVipType = new Property(14, Integer.class, "mVipType", false, "vip_type");
    }


    public UserDao(DaoConfig config) {
        super(config);
    }
    
    public UserDao(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 + "\"USER\" (" + //
                "\"_id\" INTEGER PRIMARY KEY ," + // 0: mId
                "\"user_id\" TEXT NOT NULL UNIQUE ," + // 1: mUserId
                "\"user_name\" TEXT," + // 2: mUserName
                "\"update_time\" TEXT," + // 3: mUpdateTime
                "\"mobile\" TEXT," + // 4: mMobile
                "\"nick_name\" TEXT," + // 5: mNickName
                "\"user_icon\" TEXT," + // 6: mUserIcon
                "\"avatar\" TEXT," + // 7: mAvatar
                "\"open_id\" TEXT," + // 8: mOpenId
                "\"e_mail\" TEXT," + // 9: mEmail
                "\"token\" TEXT," + // 10: mToken
                "\"user_card\" TEXT," + // 11: mUserCard
                "\"is_bind\" INTEGER," + // 12: mIsBind
                "\"is_cer\" INTEGER," + // 13: mIsCertification
                "\"vip_type\" INTEGER);"); // 14: mVipType
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, User entity) {
        stmt.clearBindings();
 
        Long mId = entity.getMId();
        if (mId != null) {
            stmt.bindLong(1, mId);
        }
        stmt.bindString(2, entity.getMUserId());
 
        String mUserName = entity.getMUserName();
        if (mUserName != null) {
            stmt.bindString(3, mUserName);
        }
 
        String mUpdateTime = entity.getMUpdateTime();
        if (mUpdateTime != null) {
            stmt.bindString(4, mUpdateTime);
        }
 
        String mMobile = entity.getMMobile();
        if (mMobile != null) {
            stmt.bindString(5, mMobile);
        }
 
        String mNickName = entity.getMNickName();
        if (mNickName != null) {
            stmt.bindString(6, mNickName);
        }
 
        String mUserIcon = entity.getMUserIcon();
        if (mUserIcon != null) {
            stmt.bindString(7, mUserIcon);
        }
 
        String mAvatar = entity.getMAvatar();
        if (mAvatar != null) {
            stmt.bindString(8, mAvatar);
        }
 
        String mOpenId = entity.getMOpenId();
        if (mOpenId != null) {
            stmt.bindString(9, mOpenId);
        }
 
        String mEmail = entity.getMEmail();
        if (mEmail != null) {
            stmt.bindString(10, mEmail);
        }
 
        String mToken = entity.getMToken();
        if (mToken != null) {
            stmt.bindString(11, mToken);
        }
 
        String mUserCard = entity.getMUserCard();
        if (mUserCard != null) {
            stmt.bindString(12, mUserCard);
        }
 
        Integer mIsBind = entity.getMIsBind();
        if (mIsBind != null) {
            stmt.bindLong(13, mIsBind);
        }
 
        Integer mIsCertification = entity.getMIsCertification();
        if (mIsCertification != null) {
            stmt.bindLong(14, mIsCertification);
        }
 
        Integer mVipType = entity.getMVipType();
        if (mVipType != null) {
            stmt.bindLong(15, mVipType);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, User entity) {
        stmt.clearBindings();
 
        Long mId = entity.getMId();
        if (mId != null) {
            stmt.bindLong(1, mId);
        }
        stmt.bindString(2, entity.getMUserId());
 
        String mUserName = entity.getMUserName();
        if (mUserName != null) {
            stmt.bindString(3, mUserName);
        }
 
        String mUpdateTime = entity.getMUpdateTime();
        if (mUpdateTime != null) {
            stmt.bindString(4, mUpdateTime);
        }
 
        String mMobile = entity.getMMobile();
        if (mMobile != null) {
            stmt.bindString(5, mMobile);
        }
 
        String mNickName = entity.getMNickName();
        if (mNickName != null) {
            stmt.bindString(6, mNickName);
        }
 
        String mUserIcon = entity.getMUserIcon();
        if (mUserIcon != null) {
            stmt.bindString(7, mUserIcon);
        }
 
        String mAvatar = entity.getMAvatar();
        if (mAvatar != null) {
            stmt.bindString(8, mAvatar);
        }
 
        String mOpenId = entity.getMOpenId();
        if (mOpenId != null) {
            stmt.bindString(9, mOpenId);
        }
 
        String mEmail = entity.getMEmail();
        if (mEmail != null) {
            stmt.bindString(10, mEmail);
        }
 
        String mToken = entity.getMToken();
        if (mToken != null) {
            stmt.bindString(11, mToken);
        }
 
        String mUserCard = entity.getMUserCard();
        if (mUserCard != null) {
            stmt.bindString(12, mUserCard);
        }
 
        Integer mIsBind = entity.getMIsBind();
        if (mIsBind != null) {
            stmt.bindLong(13, mIsBind);
        }
 
        Integer mIsCertification = entity.getMIsCertification();
        if (mIsCertification != null) {
            stmt.bindLong(14, mIsCertification);
        }
 
        Integer mVipType = entity.getMVipType();
        if (mVipType != null) {
            stmt.bindLong(15, mVipType);
        }
    }

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

    @Override
    public User readEntity(Cursor cursor, int offset) {
        User entity = new User( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // mId
            cursor.getString(offset + 1), // mUserId
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // mUserName
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // mUpdateTime
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // mMobile
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // mNickName
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // mUserIcon
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // mAvatar
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // mOpenId
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // mEmail
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // mToken
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // mUserCard
            cursor.isNull(offset + 12) ? null : cursor.getInt(offset + 12), // mIsBind
            cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13), // mIsCertification
            cursor.isNull(offset + 14) ? null : cursor.getInt(offset + 14) // mVipType
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, User entity, int offset) {
        entity.setMId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setMUserId(cursor.getString(offset + 1));
        entity.setMUserName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setMUpdateTime(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setMMobile(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setMNickName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setMUserIcon(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setMAvatar(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setMOpenId(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setMEmail(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setMToken(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setMUserCard(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setMIsBind(cursor.isNull(offset + 12) ? null : cursor.getInt(offset + 12));
        entity.setMIsCertification(cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13));
        entity.setMVipType(cursor.isNull(offset + 14) ? null : cursor.getInt(offset + 14));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(User entity, long rowId) {
        entity.setMId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(User entity) {
        if(entity != null) {
            return entity.getMId();
        } else {
            return null;
        }
    }

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

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