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.buildManage.domain.BuildHandleDataBean;

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

    public static final String TABLENAME = "DB_BUILD_HANDLE";

    /**
     * Properties of entity BuildHandleDataBean.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property Build_id = new Property(0, String.class, "build_id", true, "BUILD_ID");
        public final static Property Build_start_date = new Property(1, String.class, "build_start_date", false, "BUILD_START_DATE");
        public final static Property Build_end_date = new Property(2, String.class, "build_end_date", false, "BUILD_END_DATE");
        public final static Property Lat = new Property(3, double.class, "lat", false, "LAT");
        public final static Property Lng = new Property(4, double.class, "lng", false, "LNG");
        public final static Property Ispast = new Property(5, int.class, "ispast", false, "ISPAST");
    }


    public BuildHandleDataBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildHandleDataBeanDao(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_BUILD_HANDLE\" (" + //
                "\"BUILD_ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: build_id
                "\"BUILD_START_DATE\" TEXT," + // 1: build_start_date
                "\"BUILD_END_DATE\" TEXT," + // 2: build_end_date
                "\"LAT\" REAL NOT NULL ," + // 3: lat
                "\"LNG\" REAL NOT NULL ," + // 4: lng
                "\"ISPAST\" INTEGER NOT NULL );"); // 5: ispast
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildHandleDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getBuild_id());
 
        String build_start_date = entity.getBuild_start_date();
        if (build_start_date != null) {
            stmt.bindString(2, build_start_date);
        }
 
        String build_end_date = entity.getBuild_end_date();
        if (build_end_date != null) {
            stmt.bindString(3, build_end_date);
        }
        stmt.bindDouble(4, entity.getLat());
        stmt.bindDouble(5, entity.getLng());
        stmt.bindLong(6, entity.getIspast());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildHandleDataBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getBuild_id());
 
        String build_start_date = entity.getBuild_start_date();
        if (build_start_date != null) {
            stmt.bindString(2, build_start_date);
        }
 
        String build_end_date = entity.getBuild_end_date();
        if (build_end_date != null) {
            stmt.bindString(3, build_end_date);
        }
        stmt.bindDouble(4, entity.getLat());
        stmt.bindDouble(5, entity.getLng());
        stmt.bindLong(6, entity.getIspast());
    }

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

    @Override
    public BuildHandleDataBean readEntity(Cursor cursor, int offset) {
        BuildHandleDataBean entity = new BuildHandleDataBean( //
            cursor.getString(offset + 0), // build_id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // build_start_date
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // build_end_date
            cursor.getDouble(offset + 3), // lat
            cursor.getDouble(offset + 4), // lng
            cursor.getInt(offset + 5) // ispast
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildHandleDataBean entity, int offset) {
        entity.setBuild_id(cursor.getString(offset + 0));
        entity.setBuild_start_date(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setBuild_end_date(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setLat(cursor.getDouble(offset + 3));
        entity.setLng(cursor.getDouble(offset + 4));
        entity.setIspast(cursor.getInt(offset + 5));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildHandleDataBean entity, long rowId) {
        return entity.getBuild_id();
    }
    
    @Override
    public String getKey(BuildHandleDataBean entity) {
        if(entity != null) {
            return entity.getBuild_id();
        } else {
            return null;
        }
    }

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

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