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

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

    public static final String TABLENAME = "DB_BUILD_REPORT";

    /**
     * Properties of entity BuildReportBean.<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 Build_id = new Property(1, String.class, "build_id", false, "BUILD_ID");
        public final static Property Create_time = new Property(2, String.class, "create_time", false, "CREATE_TIME");
        public final static Property Is_leak = new Property(3, int.class, "is_leak", false, "IS_LEAK");
        public final static Property Is_notification = new Property(4, int.class, "is_notification", false, "IS_NOTIFICATION");
        public final static Property Is_pipeline = new Property(5, int.class, "is_pipeline", false, "IS_PIPELINE");
        public final static Property Is_safedistance = new Property(6, int.class, "is_safedistance", false, "IS_SAFEDISTANCE");
        public final static Property Is_safemark = new Property(7, int.class, "is_safemark", false, "IS_SAFEMARK");
        public final static Property Notes = new Property(8, String.class, "notes", false, "NOTES");
        public final static Property Report_situation = new Property(9, String.class, "report_situation", false, "REPORT_SITUATION");
        public final static Property Build_state = new Property(10, int.class, "build_state", false, "BUILD_STATE");
        public final static Property Report_state = new Property(11, int.class, "report_state", false, "REPORT_STATE");
        public final static Property Save_state = new Property(12, int.class, "save_state", false, "SAVE_STATE");
        public final static Property Report_time = new Property(13, String.class, "report_time", false, "REPORT_TIME");
        public final static Property Report_username = new Property(14, String.class, "report_username", false, "REPORT_USERNAME");
        public final static Property Address = new Property(15, String.class, "address", false, "ADDRESS");
        public final static Property Lat = new Property(16, String.class, "lat", false, "LAT");
        public final static Property Lng = new Property(17, String.class, "lng", false, "LNG");
        public final static Property Gps_flag = new Property(18, int.class, "gps_flag", false, "GPS_FLAG");
        public final static Property File = new Property(19, String.class, "file", false, "FILE");
        public final static Property Photo_report = new Property(20, String.class, "photo_report", false, "PHOTO_REPORT");
    }


    public BuildReportBeanDao(DaoConfig config) {
        super(config);
    }
    
    public BuildReportBeanDao(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_REPORT\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"BUILD_ID\" TEXT," + // 1: build_id
                "\"CREATE_TIME\" TEXT," + // 2: create_time
                "\"IS_LEAK\" INTEGER NOT NULL ," + // 3: is_leak
                "\"IS_NOTIFICATION\" INTEGER NOT NULL ," + // 4: is_notification
                "\"IS_PIPELINE\" INTEGER NOT NULL ," + // 5: is_pipeline
                "\"IS_SAFEDISTANCE\" INTEGER NOT NULL ," + // 6: is_safedistance
                "\"IS_SAFEMARK\" INTEGER NOT NULL ," + // 7: is_safemark
                "\"NOTES\" TEXT," + // 8: notes
                "\"REPORT_SITUATION\" TEXT," + // 9: report_situation
                "\"BUILD_STATE\" INTEGER NOT NULL ," + // 10: build_state
                "\"REPORT_STATE\" INTEGER NOT NULL ," + // 11: report_state
                "\"SAVE_STATE\" INTEGER NOT NULL ," + // 12: save_state
                "\"REPORT_TIME\" TEXT," + // 13: report_time
                "\"REPORT_USERNAME\" TEXT," + // 14: report_username
                "\"ADDRESS\" TEXT," + // 15: address
                "\"LAT\" TEXT," + // 16: lat
                "\"LNG\" TEXT," + // 17: lng
                "\"GPS_FLAG\" INTEGER NOT NULL ," + // 18: gps_flag
                "\"FILE\" TEXT," + // 19: file
                "\"PHOTO_REPORT\" TEXT);"); // 20: photo_report
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, BuildReportBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String build_id = entity.getBuild_id();
        if (build_id != null) {
            stmt.bindString(2, build_id);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(3, create_time);
        }
        stmt.bindLong(4, entity.getIs_leak());
        stmt.bindLong(5, entity.getIs_notification());
        stmt.bindLong(6, entity.getIs_pipeline());
        stmt.bindLong(7, entity.getIs_safedistance());
        stmt.bindLong(8, entity.getIs_safemark());
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(9, notes);
        }
 
        String report_situation = entity.getReport_situation();
        if (report_situation != null) {
            stmt.bindString(10, report_situation);
        }
        stmt.bindLong(11, entity.getBuild_state());
        stmt.bindLong(12, entity.getReport_state());
        stmt.bindLong(13, entity.getSave_state());
 
        String report_time = entity.getReport_time();
        if (report_time != null) {
            stmt.bindString(14, report_time);
        }
 
        String report_username = entity.getReport_username();
        if (report_username != null) {
            stmt.bindString(15, report_username);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(16, address);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(17, lat);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(18, lng);
        }
        stmt.bindLong(19, entity.getGps_flag());
 
        String file = entity.getFile();
        if (file != null) {
            stmt.bindString(20, file);
        }
 
        String photo_report = entity.getPhoto_report();
        if (photo_report != null) {
            stmt.bindString(21, photo_report);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, BuildReportBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String build_id = entity.getBuild_id();
        if (build_id != null) {
            stmt.bindString(2, build_id);
        }
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(3, create_time);
        }
        stmt.bindLong(4, entity.getIs_leak());
        stmt.bindLong(5, entity.getIs_notification());
        stmt.bindLong(6, entity.getIs_pipeline());
        stmt.bindLong(7, entity.getIs_safedistance());
        stmt.bindLong(8, entity.getIs_safemark());
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(9, notes);
        }
 
        String report_situation = entity.getReport_situation();
        if (report_situation != null) {
            stmt.bindString(10, report_situation);
        }
        stmt.bindLong(11, entity.getBuild_state());
        stmt.bindLong(12, entity.getReport_state());
        stmt.bindLong(13, entity.getSave_state());
 
        String report_time = entity.getReport_time();
        if (report_time != null) {
            stmt.bindString(14, report_time);
        }
 
        String report_username = entity.getReport_username();
        if (report_username != null) {
            stmt.bindString(15, report_username);
        }
 
        String address = entity.getAddress();
        if (address != null) {
            stmt.bindString(16, address);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(17, lat);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(18, lng);
        }
        stmt.bindLong(19, entity.getGps_flag());
 
        String file = entity.getFile();
        if (file != null) {
            stmt.bindString(20, file);
        }
 
        String photo_report = entity.getPhoto_report();
        if (photo_report != null) {
            stmt.bindString(21, photo_report);
        }
    }

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

    @Override
    public BuildReportBean readEntity(Cursor cursor, int offset) {
        BuildReportBean entity = new BuildReportBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // build_id
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // create_time
            cursor.getInt(offset + 3), // is_leak
            cursor.getInt(offset + 4), // is_notification
            cursor.getInt(offset + 5), // is_pipeline
            cursor.getInt(offset + 6), // is_safedistance
            cursor.getInt(offset + 7), // is_safemark
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // notes
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // report_situation
            cursor.getInt(offset + 10), // build_state
            cursor.getInt(offset + 11), // report_state
            cursor.getInt(offset + 12), // save_state
            cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13), // report_time
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // report_username
            cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15), // address
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // lat
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17), // lng
            cursor.getInt(offset + 18), // gps_flag
            cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19), // file
            cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20) // photo_report
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, BuildReportBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setBuild_id(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setCreate_time(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setIs_leak(cursor.getInt(offset + 3));
        entity.setIs_notification(cursor.getInt(offset + 4));
        entity.setIs_pipeline(cursor.getInt(offset + 5));
        entity.setIs_safedistance(cursor.getInt(offset + 6));
        entity.setIs_safemark(cursor.getInt(offset + 7));
        entity.setNotes(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setReport_situation(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setBuild_state(cursor.getInt(offset + 10));
        entity.setReport_state(cursor.getInt(offset + 11));
        entity.setSave_state(cursor.getInt(offset + 12));
        entity.setReport_time(cursor.isNull(offset + 13) ? null : cursor.getString(offset + 13));
        entity.setReport_username(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setAddress(cursor.isNull(offset + 15) ? null : cursor.getString(offset + 15));
        entity.setLat(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setLng(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
        entity.setGps_flag(cursor.getInt(offset + 18));
        entity.setFile(cursor.isNull(offset + 19) ? null : cursor.getString(offset + 19));
        entity.setPhoto_report(cursor.isNull(offset + 20) ? null : cursor.getString(offset + 20));
     }
    
    @Override
    protected final String updateKeyAfterInsert(BuildReportBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(BuildReportBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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