package com.sheep.gamegroup.greendao.download;

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;

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

    public static final String TABLENAME = "SDK_LOGIN_USER";

    /**
     * Properties of entity SdkLoginUser.<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 Token = new Property(1, String.class, "token", false, "token");
        public final static Property Nickname = new Property(2, String.class, "nickname", false, "nickname");
        public final static Property Invitation_code = new Property(3, String.class, "invitation_code", false, "invitation_code");
        public final static Property Avatar = new Property(4, String.class, "avatar", false, "avatar");
        public final static Property ServiceName = new Property(5, String.class, "serviceName", false, "service_name");
    }


    public SdkLoginUserDao(DaoConfig config) {
        super(config);
    }
    
    public SdkLoginUserDao(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 + "\"SDK_LOGIN_USER\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
                "\"token\" TEXT," + // 1: token
                "\"nickname\" TEXT," + // 2: nickname
                "\"invitation_code\" TEXT," + // 3: invitation_code
                "\"avatar\" TEXT," + // 4: avatar
                "\"service_name\" TEXT);"); // 5: serviceName
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, SdkLoginUser entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String token = entity.getToken();
        if (token != null) {
            stmt.bindString(2, token);
        }
 
        String nickname = entity.getNickname();
        if (nickname != null) {
            stmt.bindString(3, nickname);
        }
 
        String invitation_code = entity.getInvitation_code();
        if (invitation_code != null) {
            stmt.bindString(4, invitation_code);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(5, avatar);
        }
 
        String serviceName = entity.getServiceName();
        if (serviceName != null) {
            stmt.bindString(6, serviceName);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, SdkLoginUser entity) {
        stmt.clearBindings();
 
        Long id = entity.getId();
        if (id != null) {
            stmt.bindLong(1, id);
        }
 
        String token = entity.getToken();
        if (token != null) {
            stmt.bindString(2, token);
        }
 
        String nickname = entity.getNickname();
        if (nickname != null) {
            stmt.bindString(3, nickname);
        }
 
        String invitation_code = entity.getInvitation_code();
        if (invitation_code != null) {
            stmt.bindString(4, invitation_code);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(5, avatar);
        }
 
        String serviceName = entity.getServiceName();
        if (serviceName != null) {
            stmt.bindString(6, serviceName);
        }
    }

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

    @Override
    public SdkLoginUser readEntity(Cursor cursor, int offset) {
        SdkLoginUser entity = new SdkLoginUser( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // token
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // nickname
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // invitation_code
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // avatar
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // serviceName
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, SdkLoginUser entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setToken(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setNickname(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setInvitation_code(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setAvatar(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setServiceName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(SdkLoginUser entity, long rowId) {
        entity.setId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(SdkLoginUser entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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