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

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

    public static final String TABLENAME = "DB_USER_MAP_DATA";

    /**
     * Properties of entity UserMapDataBean.<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 Datatype = new Property(1, String.class, "datatype", false, "DATATYPE");
        public final static Property Dataname = new Property(2, String.class, "dataname", false, "DATANAME");
        public final static Property Filename = new Property(3, String.class, "filename", false, "FILENAME");
        public final static Property Updatetime = new Property(4, String.class, "updatetime", false, "UPDATETIME");
        public final static Property UserId = new Property(5, String.class, "userId", false, "USER_ID");
    }


    public UserMapDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public UserMapDataBeanDao(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_MAP_DATA\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL ," + // 0: id
                "\"DATATYPE\" TEXT," + // 1: datatype
                "\"DATANAME\" TEXT," + // 2: dataname
                "\"FILENAME\" TEXT," + // 3: filename
                "\"UPDATETIME\" TEXT," + // 4: updatetime
                "\"USER_ID\" TEXT);"); // 5: userId
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, UserMapDataBean entity) {
        stmt.clearBindings();
 
        String id = entity.getId();
        if (id != null) {
            stmt.bindString(1, id);
        }
 
        String datatype = entity.getDatatype();
        if (datatype != null) {
            stmt.bindString(2, datatype);
        }
 
        String dataname = entity.getDataname();
        if (dataname != null) {
            stmt.bindString(3, dataname);
        }
 
        String filename = entity.getFilename();
        if (filename != null) {
            stmt.bindString(4, filename);
        }
 
        String updatetime = entity.getUpdatetime();
        if (updatetime != null) {
            stmt.bindString(5, updatetime);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(6, userId);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UserMapDataBean entity) {
        stmt.clearBindings();
 
        String id = entity.getId();
        if (id != null) {
            stmt.bindString(1, id);
        }
 
        String datatype = entity.getDatatype();
        if (datatype != null) {
            stmt.bindString(2, datatype);
        }
 
        String dataname = entity.getDataname();
        if (dataname != null) {
            stmt.bindString(3, dataname);
        }
 
        String filename = entity.getFilename();
        if (filename != null) {
            stmt.bindString(4, filename);
        }
 
        String updatetime = entity.getUpdatetime();
        if (updatetime != null) {
            stmt.bindString(5, updatetime);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(6, userId);
        }
    }

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

    @Override
    public UserMapDataBean readEntity(Cursor cursor, int offset) {
        UserMapDataBean entity = new UserMapDataBean( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // datatype
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // dataname
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // filename
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // updatetime
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5) // userId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UserMapDataBean entity, int offset) {
        entity.setId(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setDatatype(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setDataname(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setFilename(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setUpdatetime(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setUserId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
     }
    
    @Override
    protected final String updateKeyAfterInsert(UserMapDataBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(UserMapDataBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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