package com.phlx.anchorcollect_p.db.gen;

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.phlx.anchorcollect_p.entity.UserRoleEntity;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "USER_ROLE_ENTITY".
*/
public class UserRoleEntityDao extends AbstractDao<UserRoleEntity, Void> {

    public static final String TABLENAME = "USER_ROLE_ENTITY";

    /**
     * Properties of entity UserRoleEntity.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property RoleId = new Property(0, String.class, "roleId", false, "ROLE_ID");
        public final static Property RoleName = new Property(1, String.class, "roleName", false, "ROLE_NAME");
        public final static Property RoleKey = new Property(2, String.class, "roleKey", false, "ROLE_KEY");
        public final static Property RoleSort = new Property(3, String.class, "roleSort", false, "ROLE_SORT");
        public final static Property DataScope = new Property(4, String.class, "dataScope", false, "DATA_SCOPE");
        public final static Property Status = new Property(5, String.class, "status", false, "STATUS");
        public final static Property DelFlag = new Property(6, String.class, "delFlag", false, "DEL_FLAG");
        public final static Property Flag = new Property(7, boolean.class, "flag", false, "FLAG");
    }


    public UserRoleEntityDao(DaoConfig config) {
        super(config);
    }
    
    public UserRoleEntityDao(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_ROLE_ENTITY\" (" + //
                "\"ROLE_ID\" TEXT," + // 0: roleId
                "\"ROLE_NAME\" TEXT," + // 1: roleName
                "\"ROLE_KEY\" TEXT," + // 2: roleKey
                "\"ROLE_SORT\" TEXT," + // 3: roleSort
                "\"DATA_SCOPE\" TEXT," + // 4: dataScope
                "\"STATUS\" TEXT," + // 5: status
                "\"DEL_FLAG\" TEXT," + // 6: delFlag
                "\"FLAG\" INTEGER NOT NULL );"); // 7: flag
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, UserRoleEntity entity) {
        stmt.clearBindings();
 
        String roleId = entity.getRoleId();
        if (roleId != null) {
            stmt.bindString(1, roleId);
        }
 
        String roleName = entity.getRoleName();
        if (roleName != null) {
            stmt.bindString(2, roleName);
        }
 
        String roleKey = entity.getRoleKey();
        if (roleKey != null) {
            stmt.bindString(3, roleKey);
        }
 
        String roleSort = entity.getRoleSort();
        if (roleSort != null) {
            stmt.bindString(4, roleSort);
        }
 
        String dataScope = entity.getDataScope();
        if (dataScope != null) {
            stmt.bindString(5, dataScope);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(6, status);
        }
 
        String delFlag = entity.getDelFlag();
        if (delFlag != null) {
            stmt.bindString(7, delFlag);
        }
        stmt.bindLong(8, entity.getFlag() ? 1L: 0L);
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UserRoleEntity entity) {
        stmt.clearBindings();
 
        String roleId = entity.getRoleId();
        if (roleId != null) {
            stmt.bindString(1, roleId);
        }
 
        String roleName = entity.getRoleName();
        if (roleName != null) {
            stmt.bindString(2, roleName);
        }
 
        String roleKey = entity.getRoleKey();
        if (roleKey != null) {
            stmt.bindString(3, roleKey);
        }
 
        String roleSort = entity.getRoleSort();
        if (roleSort != null) {
            stmt.bindString(4, roleSort);
        }
 
        String dataScope = entity.getDataScope();
        if (dataScope != null) {
            stmt.bindString(5, dataScope);
        }
 
        String status = entity.getStatus();
        if (status != null) {
            stmt.bindString(6, status);
        }
 
        String delFlag = entity.getDelFlag();
        if (delFlag != null) {
            stmt.bindString(7, delFlag);
        }
        stmt.bindLong(8, entity.getFlag() ? 1L: 0L);
    }

    @Override
    public Void readKey(Cursor cursor, int offset) {
        return null;
    }    

    @Override
    public UserRoleEntity readEntity(Cursor cursor, int offset) {
        UserRoleEntity entity = new UserRoleEntity( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // roleId
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // roleName
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // roleKey
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // roleSort
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // dataScope
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // status
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // delFlag
            cursor.getShort(offset + 7) != 0 // flag
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UserRoleEntity entity, int offset) {
        entity.setRoleId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setRoleName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setRoleKey(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setRoleSort(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDataScope(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setStatus(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setDelFlag(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setFlag(cursor.getShort(offset + 7) != 0);
     }
    
    @Override
    protected final Void updateKeyAfterInsert(UserRoleEntity entity, long rowId) {
        // Unsupported or missing PK type
        return null;
    }
    
    @Override
    public Void getKey(UserRoleEntity entity) {
        return null;
    }

    @Override
    public boolean hasKey(UserRoleEntity entity) {
        // TODO
        return false;
    }

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