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

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

    public static final String TABLENAME = "DB_TROUBLE_PICTURE";

    /**
     * Properties of entity TroublePictureBean.<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 Troubleid = new Property(1, String.class, "troubleid", false, "TROUBLEID");
        public final static Property Filetype = new Property(2, String.class, "filetype", false, "FILETYPE");
        public final static Property Filenote = new Property(3, String.class, "filenote", false, "FILENOTE");
        public final static Property File = new Property(4, String.class, "file", false, "FILE");
        public final static Property Thumb = new Property(5, String.class, "thumb", false, "THUMB");
        public final static Property Filepath = new Property(6, String.class, "filepath", false, "FILEPATH");
        public final static Property Fileurl = new Property(7, String.class, "fileurl", false, "FILEURL");
        public final static Property Filethumb = new Property(8, String.class, "filethumb", false, "FILETHUMB");
        public final static Property Second = new Property(9, long.class, "second", false, "SECOND");
        public final static Property Status = new Property(10, int.class, "status", false, "STATUS");
        public final static Property CreateTime = new Property(11, String.class, "createTime", false, "CREATE_TIME");
    }


    public TroublePictureBeanDao(DaoConfig config) {
        super(config);
    }
    
    public TroublePictureBeanDao(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_TROUBLE_PICTURE\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"TROUBLEID\" TEXT," + // 1: troubleid
                "\"FILETYPE\" TEXT," + // 2: filetype
                "\"FILENOTE\" TEXT," + // 3: filenote
                "\"FILE\" TEXT," + // 4: file
                "\"THUMB\" TEXT," + // 5: thumb
                "\"FILEPATH\" TEXT," + // 6: filepath
                "\"FILEURL\" TEXT," + // 7: fileurl
                "\"FILETHUMB\" TEXT," + // 8: filethumb
                "\"SECOND\" INTEGER NOT NULL ," + // 9: second
                "\"STATUS\" INTEGER NOT NULL ," + // 10: status
                "\"CREATE_TIME\" TEXT);"); // 11: createTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, TroublePictureBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String troubleid = entity.getTroubleid();
        if (troubleid != null) {
            stmt.bindString(2, troubleid);
        }
 
        String filetype = entity.getFiletype();
        if (filetype != null) {
            stmt.bindString(3, filetype);
        }
 
        String filenote = entity.getFilenote();
        if (filenote != null) {
            stmt.bindString(4, filenote);
        }
 
        String file = entity.getFile();
        if (file != null) {
            stmt.bindString(5, file);
        }
 
        String thumb = entity.getThumb();
        if (thumb != null) {
            stmt.bindString(6, thumb);
        }
 
        String filepath = entity.getFilepath();
        if (filepath != null) {
            stmt.bindString(7, filepath);
        }
 
        String fileurl = entity.getFileurl();
        if (fileurl != null) {
            stmt.bindString(8, fileurl);
        }
 
        String filethumb = entity.getFilethumb();
        if (filethumb != null) {
            stmt.bindString(9, filethumb);
        }
        stmt.bindLong(10, entity.getSecond());
        stmt.bindLong(11, entity.getStatus());
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(12, createTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, TroublePictureBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String troubleid = entity.getTroubleid();
        if (troubleid != null) {
            stmt.bindString(2, troubleid);
        }
 
        String filetype = entity.getFiletype();
        if (filetype != null) {
            stmt.bindString(3, filetype);
        }
 
        String filenote = entity.getFilenote();
        if (filenote != null) {
            stmt.bindString(4, filenote);
        }
 
        String file = entity.getFile();
        if (file != null) {
            stmt.bindString(5, file);
        }
 
        String thumb = entity.getThumb();
        if (thumb != null) {
            stmt.bindString(6, thumb);
        }
 
        String filepath = entity.getFilepath();
        if (filepath != null) {
            stmt.bindString(7, filepath);
        }
 
        String fileurl = entity.getFileurl();
        if (fileurl != null) {
            stmt.bindString(8, fileurl);
        }
 
        String filethumb = entity.getFilethumb();
        if (filethumb != null) {
            stmt.bindString(9, filethumb);
        }
        stmt.bindLong(10, entity.getSecond());
        stmt.bindLong(11, entity.getStatus());
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(12, createTime);
        }
    }

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

    @Override
    public TroublePictureBean readEntity(Cursor cursor, int offset) {
        TroublePictureBean entity = new TroublePictureBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // troubleid
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // filetype
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // filenote
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // file
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // thumb
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // filepath
            cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7), // fileurl
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8), // filethumb
            cursor.getLong(offset + 9), // second
            cursor.getInt(offset + 10), // status
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11) // createTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, TroublePictureBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setTroubleid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setFiletype(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setFilenote(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setFile(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setThumb(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setFilepath(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setFileurl(cursor.isNull(offset + 7) ? null : cursor.getString(offset + 7));
        entity.setFilethumb(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
        entity.setSecond(cursor.getLong(offset + 9));
        entity.setStatus(cursor.getInt(offset + 10));
        entity.setCreateTime(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
     }
    
    @Override
    protected final String updateKeyAfterInsert(TroublePictureBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(TroublePictureBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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