package com.tofly.data.sql.dao;

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.tofly.ghrq_route.module.user.domain.UserOnlineMapDataBean;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DB_USER_ONLINE_MAP_DATA".
*/
public class UserOnlineMapDataBeanDao extends AbstractDao<UserOnlineMapDataBean, String> {

    public static final String TABLENAME = "DB_USER_ONLINE_MAP_DATA";

    /**
     * Properties of entity UserOnlineMapDataBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Id = new Property(0, String.class, "id", true, "ID");
        public final static Property Pid = new Property(1, int.class, "pid", false, "PID");
        public final static Property Name = new Property(2, String.class, "name", false, "NAME");
        public final static Property Cval = new Property(3, String.class, "cval", false, "CVAL");
        public final static Property CreateTime = new Property(4, String.class, "createTime", false, "CREATE_TIME");
        public final static Property CreateUser = new Property(5, int.class, "createUser", false, "CREATE_USER");
        public final static Property Ckey = new Property(6, String.class, "ckey", false, "CKEY");
        public final static Property Code = new Property(7, String.class, "code", false, "CODE");
        public final static Property Userid = new Property(8, String.class, "userid", false, "USERID");
    }


    public UserOnlineMapDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public UserOnlineMapDataBeanDao(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 + "\"DB_USER_ONLINE_MAP_DATA\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"PID\" INTEGER NOT NULL ," + // 1: pid
                "\"NAME\" TEXT," + // 2: name
                "\"CVAL\" TEXT," + // 3: cval
                "\"CREATE_TIME\" TEXT," + // 4: createTime
                "\"CREATE_USER\" INTEGER NOT NULL ," + // 5: createUser
                "\"CKEY\" TEXT," + // 6: ckey
                "\"CODE\" TEXT," + // 7: code
                "\"USERID\" TEXT);"); // 8: userid
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, UserOnlineMapDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
        stmt.bindLong(2, entity.getPid());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
 
        String cval = entity.getCval();
        if (cval != null) {
            stmt.bindString(4, cval);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
        stmt.bindLong(6, entity.getCreateUser());
 
        String ckey = entity.getCkey();
        if (ckey != null) {
            stmt.bindString(7, ckey);
        }
 
        String code = entity.getCode();
        if (code != null) {
            stmt.bindString(8, code);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(9, userid);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UserOnlineMapDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
        stmt.bindLong(2, entity.getPid());
 
        String name = entity.getName();
        if (name != null) {
            stmt.bindString(3, name);
        }
 
        String cval = entity.getCval();
        if (cval != null) {
            stmt.bindString(4, cval);
        }
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(5, createTime);
        }
        stmt.bindLong(6, entity.getCreateUser());
 
        String ckey = entity.getCkey();
        if (ckey != null) {
            stmt.bindString(7, ckey);
        }
 
        String code = entity.getCode();
        if (code != null) {
            stmt.bindString(8, code);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(9, userid);
        }
    }

    @Override
    public String readKey(Cursor cursor, int offset) {
        return cursor.getString(offset + 0);
    }    

    @Override
    public UserOnlineMapDataBean readEntity(Cursor cursor, int offset) {
        UserOnlineMapDataBean entity = new UserOnlineMapDataBean( //
            cursor.getString(offset + 0), // id
            cursor.getInt(offset + 1), // pid
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // name
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // cval
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // createTime
            cursor.getInt(offset + 5), // createUser
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // ckey
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // code
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // userid
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UserOnlineMapDataBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setPid(cursor.getInt(offset + 1));
        entity.setName(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setCval(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setCreateTime(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setCreateUser(cursor.getInt(offset + 5));
        entity.setCkey(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setCode(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setUserid(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
     }
    
    @Override
    protected final String updateKeyAfterInsert(UserOnlineMapDataBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(UserOnlineMapDataBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(UserOnlineMapDataBean entity) {
        throw new UnsupportedOperationException("Unsupported for entities with a non-null key");
    }

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