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.trouble.domain.LocalPlanRecordBean;

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

    public static final String TABLENAME = "DB_LOCAL_PLAN_RECORD";

    /**
     * Properties of entity LocalPlanRecordBean.<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 Create_time = new Property(1, String.class, "create_time", false, "CREATE_TIME");
        public final static Property Create_username = new Property(2, String.class, "create_username", false, "CREATE_USERNAME");
        public final static Property Notes = new Property(3, String.class, "notes", false, "NOTES");
        public final static Property Plan_Point_id = new Property(4, String.class, "plan_Point_id", false, "PLAN__POINT_ID");
        public final static Property Point_id = new Property(5, String.class, "point_id", false, "POINT_ID");
        public final static Property Child_plan_id = new Property(6, String.class, "child_plan_id", false, "CHILD_PLAN_ID");
        public final static Property Plan_id = new Property(7, String.class, "plan_id", false, "PLAN_ID");
        public final static Property Trouble_id = new Property(8, String.class, "trouble_id", false, "TROUBLE_ID");
        public final static Property Lat = new Property(9, String.class, "lat", false, "LAT");
        public final static Property Lng = new Property(10, String.class, "lng", false, "LNG");
        public final static Property Status = new Property(11, int.class, "status", false, "STATUS");
    }


    public LocalPlanRecordBeanDao(DaoConfig config) {
        super(config);
    }
    
    public LocalPlanRecordBeanDao(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_LOCAL_PLAN_RECORD\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"CREATE_TIME\" TEXT," + // 1: create_time
                "\"CREATE_USERNAME\" TEXT," + // 2: create_username
                "\"NOTES\" TEXT," + // 3: notes
                "\"PLAN__POINT_ID\" TEXT," + // 4: plan_Point_id
                "\"POINT_ID\" TEXT," + // 5: point_id
                "\"CHILD_PLAN_ID\" TEXT," + // 6: child_plan_id
                "\"PLAN_ID\" TEXT," + // 7: plan_id
                "\"TROUBLE_ID\" TEXT," + // 8: trouble_id
                "\"LAT\" TEXT," + // 9: lat
                "\"LNG\" TEXT," + // 10: lng
                "\"STATUS\" INTEGER NOT NULL );"); // 11: status
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, LocalPlanRecordBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(2, create_time);
        }
 
        String create_username = entity.getCreate_username();
        if (create_username != null) {
            stmt.bindString(3, create_username);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(4, notes);
        }
 
        String plan_Point_id = entity.getPlan_Point_id();
        if (plan_Point_id != null) {
            stmt.bindString(5, plan_Point_id);
        }
 
        String point_id = entity.getPoint_id();
        if (point_id != null) {
            stmt.bindString(6, point_id);
        }
 
        String child_plan_id = entity.getChild_plan_id();
        if (child_plan_id != null) {
            stmt.bindString(7, child_plan_id);
        }
 
        String plan_id = entity.getPlan_id();
        if (plan_id != null) {
            stmt.bindString(8, plan_id);
        }
 
        String trouble_id = entity.getTrouble_id();
        if (trouble_id != null) {
            stmt.bindString(9, trouble_id);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(10, lat);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(11, lng);
        }
        stmt.bindLong(12, entity.getStatus());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, LocalPlanRecordBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String create_time = entity.getCreate_time();
        if (create_time != null) {
            stmt.bindString(2, create_time);
        }
 
        String create_username = entity.getCreate_username();
        if (create_username != null) {
            stmt.bindString(3, create_username);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(4, notes);
        }
 
        String plan_Point_id = entity.getPlan_Point_id();
        if (plan_Point_id != null) {
            stmt.bindString(5, plan_Point_id);
        }
 
        String point_id = entity.getPoint_id();
        if (point_id != null) {
            stmt.bindString(6, point_id);
        }
 
        String child_plan_id = entity.getChild_plan_id();
        if (child_plan_id != null) {
            stmt.bindString(7, child_plan_id);
        }
 
        String plan_id = entity.getPlan_id();
        if (plan_id != null) {
            stmt.bindString(8, plan_id);
        }
 
        String trouble_id = entity.getTrouble_id();
        if (trouble_id != null) {
            stmt.bindString(9, trouble_id);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(10, lat);
        }
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(11, lng);
        }
        stmt.bindLong(12, entity.getStatus());
    }

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

    @Override
    public LocalPlanRecordBean readEntity(Cursor cursor, int offset) {
        LocalPlanRecordBean entity = new LocalPlanRecordBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // create_time
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // create_username
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // notes
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // plan_Point_id
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // point_id
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // child_plan_id
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // plan_id
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // trouble_id
            cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9), // lat
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // lng
            cursor.getInt(offset + 11) // status
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, LocalPlanRecordBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setCreate_time(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setCreate_username(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setNotes(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setPlan_Point_id(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setPoint_id(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setChild_plan_id(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setPlan_id(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setTrouble_id(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setLat(cursor.isNull(offset + 9) ? null : cursor.getString(offset + 9));
        entity.setLng(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setStatus(cursor.getInt(offset + 11));
     }
    
    @Override
    protected final String updateKeyAfterInsert(LocalPlanRecordBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(LocalPlanRecordBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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