package suda.sudamodweather.dao.greendao;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;

import suda.sudamodweather.dao.greendao.RealWeather;

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

    public static final String TABLENAME = "REAL_WEATHER";

    /**
     * Properties of entity RealWeather.<br/>
     * Can be used for QueryBuilder and for referencing column names.
    */
    public static class Properties {
        public final static Property Areaid = new Property(0, String.class, "areaid", false, "AREAID");
        public final static Property AreaName = new Property(1, String.class, "areaName", false, "AREA_NAME");
        public final static Property WeatherCondition = new Property(2, String.class, "weatherCondition", false, "WEATHER_CONDITION");
        public final static Property Fx = new Property(3, String.class, "fx", false, "FX");
        public final static Property Fj = new Property(4, String.class, "fj", false, "FJ");
        public final static Property Temp = new Property(5, Integer.class, "temp", false, "TEMP");
        public final static Property Feeltemp = new Property(6, Integer.class, "feeltemp", false, "FEELTEMP");
        public final static Property Shidu = new Property(7, Integer.class, "shidu", false, "SHIDU");
        public final static Property Sunrise = new Property(8, String.class, "sunrise", false, "SUNRISE");
        public final static Property Sundown = new Property(9, String.class, "sundown", false, "SUNDOWN");
        public final static Property LastUpdate = new Property(10, java.util.Date.class, "lastUpdate", false, "LAST_UPDATE");
    };


    public RealWeatherDao(DaoConfig config) {
        super(config);
    }
    
    public RealWeatherDao(DaoConfig config, DaoSession daoSession) {
        super(config, daoSession);
    }

    /** Creates the underlying database table. */
    public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
        String constraint = ifNotExists? "IF NOT EXISTS ": "";
        db.execSQL("CREATE TABLE " + constraint + "\"REAL_WEATHER\" (" + //
                "\"AREAID\" TEXT," + // 0: areaid
                "\"AREA_NAME\" TEXT," + // 1: areaName
                "\"WEATHER_CONDITION\" TEXT," + // 2: weatherCondition
                "\"FX\" TEXT," + // 3: fx
                "\"FJ\" TEXT," + // 4: fj
                "\"TEMP\" INTEGER," + // 5: temp
                "\"FEELTEMP\" INTEGER," + // 6: feeltemp
                "\"SHIDU\" INTEGER," + // 7: shidu
                "\"SUNRISE\" TEXT," + // 8: sunrise
                "\"SUNDOWN\" TEXT," + // 9: sundown
                "\"LAST_UPDATE\" INTEGER);"); // 10: lastUpdate
    }

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

    /** @inheritdoc */
    @Override
    protected void bindValues(SQLiteStatement stmt, RealWeather entity) {
        stmt.clearBindings();
 
        String areaid = entity.getAreaid();
        if (areaid != null) {
            stmt.bindString(1, areaid);
        }
 
        String areaName = entity.getAreaName();
        if (areaName != null) {
            stmt.bindString(2, areaName);
        }
 
        String weatherCondition = entity.getWeatherCondition();
        if (weatherCondition != null) {
            stmt.bindString(3, weatherCondition);
        }
 
        String fx = entity.getFx();
        if (fx != null) {
            stmt.bindString(4, fx);
        }
 
        String fj = entity.getFj();
        if (fj != null) {
            stmt.bindString(5, fj);
        }
 
        Integer temp = entity.getTemp();
        if (temp != null) {
            stmt.bindLong(6, temp);
        }
 
        Integer feeltemp = entity.getFeeltemp();
        if (feeltemp != null) {
            stmt.bindLong(7, feeltemp);
        }
 
        Integer shidu = entity.getShidu();
        if (shidu != null) {
            stmt.bindLong(8, shidu);
        }
 
        String sunrise = entity.getSunrise();
        if (sunrise != null) {
            stmt.bindString(9, sunrise);
        }
 
        String sundown = entity.getSundown();
        if (sundown != null) {
            stmt.bindString(10, sundown);
        }
 
        java.util.Date lastUpdate = entity.getLastUpdate();
        if (lastUpdate != null) {
            stmt.bindLong(11, lastUpdate.getTime());
        }
    }

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

    /** @inheritdoc */
    @Override
    public RealWeather readEntity(Cursor cursor, int offset) {
        RealWeather entity = new RealWeather( //
            cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0), // areaid
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // areaName
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // weatherCondition
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // fx
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // fj
            cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // temp
            cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6), // feeltemp
            cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7), // shidu
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // sunrise
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // sundown
            cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)) // lastUpdate
        );
        return entity;
    }
     
    /** @inheritdoc */
    @Override
    public void readEntity(Cursor cursor, RealWeather entity, int offset) {
        entity.setAreaid(cursor.isNull(offset + 0) ? null : cursor.getString(offset + 0));
        entity.setAreaName(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setWeatherCondition(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setFx(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setFj(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setTemp(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
        entity.setFeeltemp(cursor.isNull(offset + 6) ? null : cursor.getInt(offset + 6));
        entity.setShidu(cursor.isNull(offset + 7) ? null : cursor.getInt(offset + 7));
        entity.setSunrise(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setSundown(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setLastUpdate(cursor.isNull(offset + 10) ? null : new java.util.Date(cursor.getLong(offset + 10)));
     }
    
    /** @inheritdoc */
    @Override
    protected Void updateKeyAfterInsert(RealWeather entity, long rowId) {
        // Unsupported or missing PK type
        return null;
    }
    
    /** @inheritdoc */
    @Override
    public Void getKey(RealWeather entity) {
        return null;
    }

    /** @inheritdoc */
    @Override    
    protected boolean isEntityUpdateable() {
        return true;
    }
    
}