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

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

    public static final String TABLENAME = "DB_MAP_URL_CONFIG_DATA";

    /**
     * Properties of entity MapUrlConfigDataBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Offsetx = new Property(0, String.class, "offsetx", false, "OFFSETX");
        public final static Property Offsety = new Property(1, String.class, "offsety", false, "OFFSETY");
        public final static Property Bursturl = new Property(2, String.class, "bursturl", false, "BURSTURL");
        public final static Property Pipeurl = new Property(3, String.class, "pipeurl", false, "PIPEURL");
        public final static Property Dxturl = new Property(4, String.class, "dxturl", false, "DXTURL");
        public final static Property Poiurl = new Property(5, String.class, "poiurl", false, "POIURL");
        public final static Property UserId = new Property(6, String.class, "userId", true, "USER_ID");
    }


    public MapUrlConfigDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public MapUrlConfigDataBeanDao(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_MAP_URL_CONFIG_DATA\" (" + //
                "\"OFFSETX\" TEXT," + // 0: offsetx
                "\"OFFSETY\" TEXT," + // 1: offsety
                "\"BURSTURL\" TEXT," + // 2: bursturl
                "\"PIPEURL\" TEXT," + // 3: pipeurl
                "\"DXTURL\" TEXT," + // 4: dxturl
                "\"POIURL\" TEXT," + // 5: poiurl
                "\"USER_ID\" TEXT PRIMARY KEY NOT NULL );"); // 6: userId
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, MapUrlConfigDataBean entity) {
        stmt.clearBindings();
 
        String offsetx = entity.getOffsetx();
        if (offsetx != null) {
            stmt.bindString(1, offsetx);
        }
 
        String offsety = entity.getOffsety();
        if (offsety != null) {
            stmt.bindString(2, offsety);
        }
 
        String bursturl = entity.getBursturl();
        if (bursturl != null) {
            stmt.bindString(3, bursturl);
        }
 
        String pipeurl = entity.getPipeurl();
        if (pipeurl != null) {
            stmt.bindString(4, pipeurl);
        }
 
        String dxturl = entity.getDxturl();
        if (dxturl != null) {
            stmt.bindString(5, dxturl);
        }
 
        String poiurl = entity.getPoiurl();
        if (poiurl != null) {
            stmt.bindString(6, poiurl);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(7, userId);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, MapUrlConfigDataBean entity) {
        stmt.clearBindings();
 
        String offsetx = entity.getOffsetx();
        if (offsetx != null) {
            stmt.bindString(1, offsetx);
        }
 
        String offsety = entity.getOffsety();
        if (offsety != null) {
            stmt.bindString(2, offsety);
        }
 
        String bursturl = entity.getBursturl();
        if (bursturl != null) {
            stmt.bindString(3, bursturl);
        }
 
        String pipeurl = entity.getPipeurl();
        if (pipeurl != null) {
            stmt.bindString(4, pipeurl);
        }
 
        String dxturl = entity.getDxturl();
        if (dxturl != null) {
            stmt.bindString(5, dxturl);
        }
 
        String poiurl = entity.getPoiurl();
        if (poiurl != null) {
            stmt.bindString(6, poiurl);
        }
 
        String userId = entity.getUserId();
        if (userId != null) {
            stmt.bindString(7, userId);
        }
    }

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

    @Override
    public MapUrlConfigDataBean readEntity(Cursor cursor, int offset) {
        MapUrlConfigDataBean entity = new MapUrlConfigDataBean( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // offsetx
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // offsety
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // bursturl
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // pipeurl
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // dxturl
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // poiurl
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6) // userId
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, MapUrlConfigDataBean entity, int offset) {
        entity.setOffsetx(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setOffsety(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setBursturl(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setPipeurl(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setDxturl(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setPoiurl(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setUserId(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
     }
    
    @Override
    protected final String updateKeyAfterInsert(MapUrlConfigDataBean entity, long rowId) {
        return entity.getUserId();
    }
    
    @Override
    public String getKey(MapUrlConfigDataBean entity) {
        if(entity != null) {
            return entity.getUserId();
        } else {
            return null;
        }
    }

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

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