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

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

    public static final String TABLENAME = "DB_TROUBLE_AUDIO";

    /**
     * Properties of entity TroubleAudioBean.<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 Path = new Property(2, String.class, "path", false, "PATH");
        public final static Property Url = new Property(3, String.class, "url", false, "URL");
        public final static Property Second = new Property(4, int.class, "second", false, "SECOND");
        public final static Property Filetype = new Property(5, String.class, "filetype", false, "FILETYPE");
        public final static Property Filenote = new Property(6, String.class, "filenote", false, "FILENOTE");
        public final static Property Status = new Property(7, int.class, "status", false, "STATUS");
        public final static Property CreateTime = new Property(8, String.class, "createTime", false, "CREATE_TIME");
    }


    public TroubleAudioBeanDao(DaoConfig config) {
        super(config);
    }
    
    public TroubleAudioBeanDao(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_AUDIO\" (" + //
                "\"ID\" TEXT PRIMARY KEY NOT NULL UNIQUE ," + // 0: id
                "\"TROUBLEID\" TEXT," + // 1: troubleid
                "\"PATH\" TEXT," + // 2: path
                "\"URL\" TEXT," + // 3: url
                "\"SECOND\" INTEGER NOT NULL ," + // 4: second
                "\"FILETYPE\" TEXT," + // 5: filetype
                "\"FILENOTE\" TEXT," + // 6: filenote
                "\"STATUS\" INTEGER NOT NULL ," + // 7: status
                "\"CREATE_TIME\" TEXT);"); // 8: createTime
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, TroubleAudioBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String troubleid = entity.getTroubleid();
        if (troubleid != null) {
            stmt.bindString(2, troubleid);
        }
 
        String path = entity.getPath();
        if (path != null) {
            stmt.bindString(3, path);
        }
 
        String url = entity.getUrl();
        if (url != null) {
            stmt.bindString(4, url);
        }
        stmt.bindLong(5, entity.getSecond());
 
        String filetype = entity.getFiletype();
        if (filetype != null) {
            stmt.bindString(6, filetype);
        }
 
        String filenote = entity.getFilenote();
        if (filenote != null) {
            stmt.bindString(7, filenote);
        }
        stmt.bindLong(8, entity.getStatus());
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(9, createTime);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, TroubleAudioBean entity) {
        stmt.clearBindings();
        stmt.bindString(1, entity.getId());
 
        String troubleid = entity.getTroubleid();
        if (troubleid != null) {
            stmt.bindString(2, troubleid);
        }
 
        String path = entity.getPath();
        if (path != null) {
            stmt.bindString(3, path);
        }
 
        String url = entity.getUrl();
        if (url != null) {
            stmt.bindString(4, url);
        }
        stmt.bindLong(5, entity.getSecond());
 
        String filetype = entity.getFiletype();
        if (filetype != null) {
            stmt.bindString(6, filetype);
        }
 
        String filenote = entity.getFilenote();
        if (filenote != null) {
            stmt.bindString(7, filenote);
        }
        stmt.bindLong(8, entity.getStatus());
 
        String createTime = entity.getCreateTime();
        if (createTime != null) {
            stmt.bindString(9, createTime);
        }
    }

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

    @Override
    public TroubleAudioBean readEntity(Cursor cursor, int offset) {
        TroubleAudioBean entity = new TroubleAudioBean( //
            cursor.getString(offset + 0), // id
            cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // troubleid
            cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // path
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // url
            cursor.getInt(offset + 4), // second
            cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5), // filetype
            cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6), // filenote
            cursor.getInt(offset + 7), // status
            cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8) // createTime
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, TroubleAudioBean entity, int offset) {
        entity.setId(cursor.getString(offset + 0));
        entity.setTroubleid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
        entity.setPath(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
        entity.setUrl(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setSecond(cursor.getInt(offset + 4));
        entity.setFiletype(cursor.isNull(offset + 5) ? null : cursor.getString(offset + 5));
        entity.setFilenote(cursor.isNull(offset + 6) ? null : cursor.getString(offset + 6));
        entity.setStatus(cursor.getInt(offset + 7));
        entity.setCreateTime(cursor.isNull(offset + 8) ? null : cursor.getString(offset + 8));
     }
    
    @Override
    protected final String updateKeyAfterInsert(TroubleAudioBean entity, long rowId) {
        return entity.getId();
    }
    
    @Override
    public String getKey(TroubleAudioBean entity) {
        if(entity != null) {
            return entity.getId();
        } else {
            return null;
        }
    }

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

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