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.uploadPhoto.domain.UploadPhotoBean;

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

    public static final String TABLENAME = "DB_UPLOAD_PHOTO_INFO";

    /**
     * Properties of entity UploadPhotoBean.<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 Lng = new Property(1, String.class, "lng", false, "LNG");
        public final static Property Lat = new Property(2, String.class, "lat", false, "LAT");
        public final static Property GpsFlag = new Property(3, int.class, "gpsFlag", false, "GPS_FLAG");
        public final static Property Addr = new Property(4, String.class, "addr", false, "ADDR");
        public final static Property PicTypeId = new Property(5, String.class, "picTypeId", false, "PIC_TYPE_ID");
        public final static Property Notes = new Property(6, String.class, "notes", false, "NOTES");
        public final static Property FindTime = new Property(7, String.class, "findTime", false, "FIND_TIME");
        public final static Property Userid = new Property(8, String.class, "userid", false, "USERID");
        public final static Property State = new Property(9, int.class, "state", false, "STATE");
    }


    public UploadPhotoBeanDao(DaoConfig config) {
        super(config);
    }
    
    public UploadPhotoBeanDao(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_UPLOAD_PHOTO_INFO\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"LNG\" TEXT," + // 1: lng
                "\"LAT\" TEXT," + // 2: lat
                "\"GPS_FLAG\" INTEGER NOT NULL ," + // 3: gpsFlag
                "\"ADDR\" TEXT," + // 4: addr
                "\"PIC_TYPE_ID\" TEXT," + // 5: picTypeId
                "\"NOTES\" TEXT," + // 6: notes
                "\"FIND_TIME\" TEXT," + // 7: findTime
                "\"USERID\" TEXT," + // 8: userid
                "\"STATE\" INTEGER NOT NULL );"); // 9: state
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, UploadPhotoBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(2, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(3, lat);
        }
        stmt.bindLong(4, entity.getGpsFlag());
 
        String addr = entity.getAddr();
        if (addr != null) {
            stmt.bindString(5, addr);
        }
 
        String picTypeId = entity.getPicTypeId();
        if (picTypeId != null) {
            stmt.bindString(6, picTypeId);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(7, notes);
        }
 
        String findTime = entity.getFindTime();
        if (findTime != null) {
            stmt.bindString(8, findTime);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(9, userid);
        }
        stmt.bindLong(10, entity.getState());
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, UploadPhotoBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String lng = entity.getLng();
        if (lng != null) {
            stmt.bindString(2, lng);
        }
 
        String lat = entity.getLat();
        if (lat != null) {
            stmt.bindString(3, lat);
        }
        stmt.bindLong(4, entity.getGpsFlag());
 
        String addr = entity.getAddr();
        if (addr != null) {
            stmt.bindString(5, addr);
        }
 
        String picTypeId = entity.getPicTypeId();
        if (picTypeId != null) {
            stmt.bindString(6, picTypeId);
        }
 
        String notes = entity.getNotes();
        if (notes != null) {
            stmt.bindString(7, notes);
        }
 
        String findTime = entity.getFindTime();
        if (findTime != null) {
            stmt.bindString(8, findTime);
        }
 
        String userid = entity.getUserid();
        if (userid != null) {
            stmt.bindString(9, userid);
        }
        stmt.bindLong(10, entity.getState());
    }

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

    @Override
    public UploadPhotoBean readEntity(Cursor cursor, int offset) {
        UploadPhotoBean entity = new UploadPhotoBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // lng
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // lat
            cursor.getInt(offset + 3), // gpsFlag
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // addr
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // picTypeId
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // notes
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // findTime
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // userid
            cursor.getInt(offset + 9) // state
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, UploadPhotoBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setLng(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setLat(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setGpsFlag(cursor.getInt(offset + 3));
        entity.setAddr(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setPicTypeId(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setNotes(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setFindTime(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setUserid(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setState(cursor.getInt(offset + 9));
     }
    
    @Override
    protected final String updateKeyAfterInsert(UploadPhotoBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(UploadPhotoBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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