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.UserBean;

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

    public static final String TABLENAME = "DB_USER";

    /**
     * Properties of entity UserBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Userid = new Property(0, String.class, "userid", true, "USERID");
        public final static Property Username = new Property(1, String.class, "username", false, "USERNAME");
        public final static Property Password = new Property(2, String.class, "password", false, "PASSWORD");
        public final static Property Token = new Property(3, String.class, "token", false, "TOKEN");
        public final static Property Avatar = new Property(4, String.class, "avatar", false, "AVATAR");
        public final static Property RealName = new Property(5, String.class, "realName", false, "REAL_NAME");
        public final static Property UserLevel = new Property(6, String.class, "userLevel", false, "USER_LEVEL");
        public final static Property Companyid = new Property(7, String.class, "companyid", false, "COMPANYID");
        public final static Property Company_name = new Property(8, String.class, "company_name", false, "COMPANY_NAME");
        public final static Property DepartmentId = new Property(9, String.class, "departmentId", false, "DEPARTMENT_ID");
        public final static Property DepartmentName = new Property(10, String.class, "departmentName", false, "DEPARTMENT_NAME");
        public final static Property Logintime = new Property(11, String.class, "logintime", false, "LOGINTIME");
        public final static Property Mobile = new Property(12, String.class, "mobile", false, "MOBILE");
        public final static Property Online = new Property(13, String.class, "online", false, "ONLINE");
        public final static Property Pdaid = new Property(14, String.class, "pdaid", false, "PDAID");
        public final static Property State = new Property(15, String.class, "state", false, "STATE");
        public final static Property Patrol_type = new Property(16, int.class, "patrol_type", false, "PATROL_TYPE");
        public final static Property Carid = new Property(17, String.class, "carid", false, "CARID");
        public final static Property Plate_number = new Property(18, String.class, "plate_number", false, "PLATE_NUMBER");
        public final static Property Car_mode = new Property(19, int.class, "car_mode", false, "CAR_MODE");
    }


    public UserBeanDao(DaoConfig config) {
        super(config);
    }
    
    public UserBeanDao(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\" (" + //
                "\"USERID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: userid
                "\"USERNAME\" TEXT," + // 1: username
                "\"PASSWORD\" TEXT," + // 2: password
                "\"TOKEN\" TEXT," + // 3: token
                "\"AVATAR\" TEXT," + // 4: avatar
                "\"REAL_NAME\" TEXT," + // 5: realName
                "\"USER_LEVEL\" TEXT," + // 6: userLevel
                "\"COMPANYID\" TEXT," + // 7: companyid
                "\"COMPANY_NAME\" TEXT," + // 8: company_name
                "\"DEPARTMENT_ID\" TEXT," + // 9: departmentId
                "\"DEPARTMENT_NAME\" TEXT," + // 10: departmentName
                "\"LOGINTIME\" TEXT," + // 11: logintime
                "\"MOBILE\" TEXT," + // 12: mobile
                "\"ONLINE\" TEXT," + // 13: online
                "\"PDAID\" TEXT," + // 14: pdaid
                "\"STATE\" TEXT," + // 15: state
                "\"PATROL_TYPE\" INTEGER NOT NULL ," + // 16: patrol_type
                "\"CARID\" TEXT," + // 17: carid
                "\"PLATE_NUMBER\" TEXT," + // 18: plate_number
                "\"CAR_MODE\" INTEGER NOT NULL );"); // 19: car_mode
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, UserBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUserid());
 
        String username = entity.getUsername();
        if (username != null) {
            stmt.bindString(2, username);
        }
 
        String password = entity.getPassword();
        if (password != null) {
            stmt.bindString(3, password);
        }
 
        String token = entity.getToken();
        if (token != null) {
            stmt.bindString(4, token);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(5, avatar);
        }
 
        String realName = entity.getRealName();
        if (realName != null) {
            stmt.bindString(6, realName);
        }
 
        String userLevel = entity.getUserLevel();
        if (userLevel != null) {
            stmt.bindString(7, userLevel);
        }
 
        String companyid = entity.getCompanyid();
        if (companyid != null) {
            stmt.bindString(8, companyid);
        }
 
        String company_name = entity.getCompany_name();
        if (company_name != null) {
            stmt.bindString(9, company_name);
        }
 
        String departmentId = entity.getDepartmentId();
        if (departmentId != null) {
            stmt.bindString(10, departmentId);
        }
 
        String departmentName = entity.getDepartmentName();
        if (departmentName != null) {
            stmt.bindString(11, departmentName);
        }
 
        String logintime = entity.getLogintime();
        if (logintime != null) {
            stmt.bindString(12, logintime);
        }
 
        String mobile = entity.getMobile();
        if (mobile != null) {
            stmt.bindString(13, mobile);
        }
 
        String online = entity.getOnline();
        if (online != null) {
            stmt.bindString(14, online);
        }
 
        String pdaid = entity.getPdaid();
        if (pdaid != null) {
            stmt.bindString(15, pdaid);
        }
 
        String state = entity.getState();
        if (state != null) {
            stmt.bindString(16, state);
        }
        stmt.bindLong(17, entity.getPatrol_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(18, carid);
        }
 
        String plate_number = entity.getPlate_number();
        if (plate_number != null) {
            stmt.bindString(19, plate_number);
        }
        stmt.bindLong(20, entity.getCar_mode());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UserBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getUserid());
 
        String username = entity.getUsername();
        if (username != null) {
            stmt.bindString(2, username);
        }
 
        String password = entity.getPassword();
        if (password != null) {
            stmt.bindString(3, password);
        }
 
        String token = entity.getToken();
        if (token != null) {
            stmt.bindString(4, token);
        }
 
        String avatar = entity.getAvatar();
        if (avatar != null) {
            stmt.bindString(5, avatar);
        }
 
        String realName = entity.getRealName();
        if (realName != null) {
            stmt.bindString(6, realName);
        }
 
        String userLevel = entity.getUserLevel();
        if (userLevel != null) {
            stmt.bindString(7, userLevel);
        }
 
        String companyid = entity.getCompanyid();
        if (companyid != null) {
            stmt.bindString(8, companyid);
        }
 
        String company_name = entity.getCompany_name();
        if (company_name != null) {
            stmt.bindString(9, company_name);
        }
 
        String departmentId = entity.getDepartmentId();
        if (departmentId != null) {
            stmt.bindString(10, departmentId);
        }
 
        String departmentName = entity.getDepartmentName();
        if (departmentName != null) {
            stmt.bindString(11, departmentName);
        }
 
        String logintime = entity.getLogintime();
        if (logintime != null) {
            stmt.bindString(12, logintime);
        }
 
        String mobile = entity.getMobile();
        if (mobile != null) {
            stmt.bindString(13, mobile);
        }
 
        String online = entity.getOnline();
        if (online != null) {
            stmt.bindString(14, online);
        }
 
        String pdaid = entity.getPdaid();
        if (pdaid != null) {
            stmt.bindString(15, pdaid);
        }
 
        String state = entity.getState();
        if (state != null) {
            stmt.bindString(16, state);
        }
        stmt.bindLong(17, entity.getPatrol_type());
 
        String carid = entity.getCarid();
        if (carid != null) {
            stmt.bindString(18, carid);
        }
 
        String plate_number = entity.getPlate_number();
        if (plate_number != null) {
            stmt.bindString(19, plate_number);
        }
        stmt.bindLong(20, entity.getCar_mode());
    }

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

    @Override
    public UserBean readEntity(Cursor cursor, int offset) {
        UserBean entity = new UserBean( //
            cursor.getString(offset + 0), // userid
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // username
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // password
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // token
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // avatar
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // realName
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // userLevel
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // companyid
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // company_name
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // departmentId
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // departmentName
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // logintime
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // mobile
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // online
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // pdaid
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // state
            cursor.getInt(offset + 16), // patrol_type
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // carid
            cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18), // plate_number
            cursor.getInt(offset + 19) // car_mode
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UserBean entity, int offset) {
        entity.setUserid(cursor.getString(offset + 0));
        entity.setUsername(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setPassword(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setToken(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setAvatar(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setRealName(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setUserLevel(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setCompanyid(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setCompany_name(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setDepartmentId(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setDepartmentName(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setLogintime(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setMobile(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setOnline(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setPdaid(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setState(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setPatrol_type(cursor.getInt(offset + 16));
        entity.setCarid(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setPlate_number(cursor.isNull(offset + 18) ? null : cursor.getString(offset + 18));
        entity.setCar_mode(cursor.getInt(offset + 19));
     }
    
    @Override
    protected final String updateKeyAfterInsert(UserBean entity, long rowId) {
        return entity.getUserid();
    }
    
    @Override
    public String getKey(UserBean entity) {
        if(entity != null) {
            return entity.getUserid();
        } else {
            return null;
        }
    }

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

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