package com.sheep.gamegroup.greendao.download;

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;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * DAO for table "DOWN_LOAD_INFO".
*/
public class DownLoadInfoDao extends AbstractDao<DownLoadInfo, Long> {

    public static final String TABLENAME = "DOWN_LOAD_INFO";

    /**
     * Properties of entity DownLoadInfo.<br/>
     * Can be used for QueryBuilder and for referencing column names.
     */
    public static class Properties {
        public final static Property MId = new Property(0, Long.class, "mId", true, "_id");
        public final static Property MCreateTime = new Property(1, Long.class, "mCreateTime", false, "creat_time");
        public final static Property MDownloadTaskId = new Property(2, Integer.class, "mDownloadTaskId", false, "download_task_id");
        public final static Property MGameName = new Property(3, String.class, "mGameName", false, "game_name");
        public final static Property MIconUrl = new Property(4, String.class, "mIconUrl", false, "icon_url");
        public final static Property MPercent = new Property(5, Integer.class, "mPercent", false, "percent");
        public final static Property MGameID = new Property(6, int.class, "mGameID", false, "game_id");
        public final static Property MDownloadedSize = new Property(7, Double.class, "mDownloadedSize", false, "download_size");
        public final static Property MTotalSize = new Property(8, Double.class, "mTotalSize", false, "total_size");
        public final static Property MStatus = new Property(9, Integer.class, "mStatus", false, "status");
        public final static Property MDownloadUrl = new Property(10, String.class, "mDownloadUrl", false, "download_url");
        public final static Property MChannelDownloadUrl = new Property(11, String.class, "mChannelDownloadUrl", false, "channel_download_url");
        public final static Property MPackageName = new Property(12, String.class, "mPackageName", false, "package_name");
        public final static Property MVersionCode = new Property(13, Integer.class, "mVersionCode", false, "version_code");
        public final static Property MApkPath = new Property(14, String.class, "mApkPath", false, "apk_path");
        public final static Property WhereFrom = new Property(15, int.class, "whereFrom", false, "where_from");
        public final static Property AverageSpeed = new Property(16, String.class, "averageSpeed", false, "average_speed");
        public final static Property RealCauseMsg = new Property(17, String.class, "realCauseMsg", false, "real_cause_msg");
    }


    public DownLoadInfoDao(DaoConfig config) {
        super(config);
    }
    
    public DownLoadInfoDao(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 + "\"DOWN_LOAD_INFO\" (" + //
                "\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: mId
                "\"creat_time\" INTEGER," + // 1: mCreateTime
                "\"download_task_id\" INTEGER," + // 2: mDownloadTaskId
                "\"game_name\" TEXT," + // 3: mGameName
                "\"icon_url\" TEXT," + // 4: mIconUrl
                "\"percent\" INTEGER," + // 5: mPercent
                "\"game_id\" INTEGER NOT NULL ," + // 6: mGameID
                "\"download_size\" REAL," + // 7: mDownloadedSize
                "\"total_size\" REAL," + // 8: mTotalSize
                "\"status\" INTEGER," + // 9: mStatus
                "\"download_url\" TEXT UNIQUE ," + // 10: mDownloadUrl
                "\"channel_download_url\" TEXT UNIQUE ," + // 11: mChannelDownloadUrl
                "\"package_name\" TEXT," + // 12: mPackageName
                "\"version_code\" INTEGER," + // 13: mVersionCode
                "\"apk_path\" TEXT," + // 14: mApkPath
                "\"where_from\" INTEGER NOT NULL ," + // 15: whereFrom
                "\"average_speed\" TEXT," + // 16: averageSpeed
                "\"real_cause_msg\" TEXT);"); // 17: realCauseMsg
    }

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

    @Override
    protected final void bindValues(DatabaseStatement stmt, DownLoadInfo entity) {
        stmt.clearBindings();
 
        Long mId = entity.getMId();
        if (mId != null) {
            stmt.bindLong(1, mId);
        }
 
        Long mCreateTime = entity.getMCreateTime();
        if (mCreateTime != null) {
            stmt.bindLong(2, mCreateTime);
        }
 
        Integer mDownloadTaskId = entity.getMDownloadTaskId();
        if (mDownloadTaskId != null) {
            stmt.bindLong(3, mDownloadTaskId);
        }
 
        String mGameName = entity.getMGameName();
        if (mGameName != null) {
            stmt.bindString(4, mGameName);
        }
 
        String mIconUrl = entity.getMIconUrl();
        if (mIconUrl != null) {
            stmt.bindString(5, mIconUrl);
        }
 
        Integer mPercent = entity.getMPercent();
        if (mPercent != null) {
            stmt.bindLong(6, mPercent);
        }
        stmt.bindLong(7, entity.getMGameID());
 
        Double mDownloadedSize = entity.getMDownloadedSize();
        if (mDownloadedSize != null) {
            stmt.bindDouble(8, mDownloadedSize);
        }
 
        Double mTotalSize = entity.getMTotalSize();
        if (mTotalSize != null) {
            stmt.bindDouble(9, mTotalSize);
        }
 
        Integer mStatus = entity.getMStatus();
        if (mStatus != null) {
            stmt.bindLong(10, mStatus);
        }
 
        String mDownloadUrl = entity.getMDownloadUrl();
        if (mDownloadUrl != null) {
            stmt.bindString(11, mDownloadUrl);
        }
 
        String mChannelDownloadUrl = entity.getMChannelDownloadUrl();
        if (mChannelDownloadUrl != null) {
            stmt.bindString(12, mChannelDownloadUrl);
        }
 
        String mPackageName = entity.getMPackageName();
        if (mPackageName != null) {
            stmt.bindString(13, mPackageName);
        }
 
        Integer mVersionCode = entity.getMVersionCode();
        if (mVersionCode != null) {
            stmt.bindLong(14, mVersionCode);
        }
 
        String mApkPath = entity.getMApkPath();
        if (mApkPath != null) {
            stmt.bindString(15, mApkPath);
        }
        stmt.bindLong(16, entity.getWhereFrom());
 
        String averageSpeed = entity.getAverageSpeed();
        if (averageSpeed != null) {
            stmt.bindString(17, averageSpeed);
        }
 
        String realCauseMsg = entity.getRealCauseMsg();
        if (realCauseMsg != null) {
            stmt.bindString(18, realCauseMsg);
        }
    }

    @Override
    protected final void bindValues(SQLiteStatement stmt, DownLoadInfo entity) {
        stmt.clearBindings();
 
        Long mId = entity.getMId();
        if (mId != null) {
            stmt.bindLong(1, mId);
        }
 
        Long mCreateTime = entity.getMCreateTime();
        if (mCreateTime != null) {
            stmt.bindLong(2, mCreateTime);
        }
 
        Integer mDownloadTaskId = entity.getMDownloadTaskId();
        if (mDownloadTaskId != null) {
            stmt.bindLong(3, mDownloadTaskId);
        }
 
        String mGameName = entity.getMGameName();
        if (mGameName != null) {
            stmt.bindString(4, mGameName);
        }
 
        String mIconUrl = entity.getMIconUrl();
        if (mIconUrl != null) {
            stmt.bindString(5, mIconUrl);
        }
 
        Integer mPercent = entity.getMPercent();
        if (mPercent != null) {
            stmt.bindLong(6, mPercent);
        }
        stmt.bindLong(7, entity.getMGameID());
 
        Double mDownloadedSize = entity.getMDownloadedSize();
        if (mDownloadedSize != null) {
            stmt.bindDouble(8, mDownloadedSize);
        }
 
        Double mTotalSize = entity.getMTotalSize();
        if (mTotalSize != null) {
            stmt.bindDouble(9, mTotalSize);
        }
 
        Integer mStatus = entity.getMStatus();
        if (mStatus != null) {
            stmt.bindLong(10, mStatus);
        }
 
        String mDownloadUrl = entity.getMDownloadUrl();
        if (mDownloadUrl != null) {
            stmt.bindString(11, mDownloadUrl);
        }
 
        String mChannelDownloadUrl = entity.getMChannelDownloadUrl();
        if (mChannelDownloadUrl != null) {
            stmt.bindString(12, mChannelDownloadUrl);
        }
 
        String mPackageName = entity.getMPackageName();
        if (mPackageName != null) {
            stmt.bindString(13, mPackageName);
        }
 
        Integer mVersionCode = entity.getMVersionCode();
        if (mVersionCode != null) {
            stmt.bindLong(14, mVersionCode);
        }
 
        String mApkPath = entity.getMApkPath();
        if (mApkPath != null) {
            stmt.bindString(15, mApkPath);
        }
        stmt.bindLong(16, entity.getWhereFrom());
 
        String averageSpeed = entity.getAverageSpeed();
        if (averageSpeed != null) {
            stmt.bindString(17, averageSpeed);
        }
 
        String realCauseMsg = entity.getRealCauseMsg();
        if (realCauseMsg != null) {
            stmt.bindString(18, realCauseMsg);
        }
    }

    @Override
    public Long readKey(Cursor cursor, int offset) {
        return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
    }    

    @Override
    public DownLoadInfo readEntity(Cursor cursor, int offset) {
        DownLoadInfo entity = new DownLoadInfo( //
            cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // mId
            cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1), // mCreateTime
            cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2), // mDownloadTaskId
            cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // mGameName
            cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // mIconUrl
            cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // mPercent
            cursor.getInt(offset + 6), // mGameID
            cursor.isNull(offset + 7) ? null : cursor.getDouble(offset + 7), // mDownloadedSize
            cursor.isNull(offset + 8) ? null : cursor.getDouble(offset + 8), // mTotalSize
            cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9), // mStatus
            cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10), // mDownloadUrl
            cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11), // mChannelDownloadUrl
            cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12), // mPackageName
            cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13), // mVersionCode
            cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14), // mApkPath
            cursor.getInt(offset + 15), // whereFrom
            cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16), // averageSpeed
            cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17) // realCauseMsg
        );
        return entity;
    }
     
    @Override
    public void readEntity(Cursor cursor, DownLoadInfo entity, int offset) {
        entity.setMId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
        entity.setMCreateTime(cursor.isNull(offset + 1) ? null : cursor.getLong(offset + 1));
        entity.setMDownloadTaskId(cursor.isNull(offset + 2) ? null : cursor.getInt(offset + 2));
        entity.setMGameName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
        entity.setMIconUrl(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
        entity.setMPercent(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
        entity.setMGameID(cursor.getInt(offset + 6));
        entity.setMDownloadedSize(cursor.isNull(offset + 7) ? null : cursor.getDouble(offset + 7));
        entity.setMTotalSize(cursor.isNull(offset + 8) ? null : cursor.getDouble(offset + 8));
        entity.setMStatus(cursor.isNull(offset + 9) ? null : cursor.getInt(offset + 9));
        entity.setMDownloadUrl(cursor.isNull(offset + 10) ? null : cursor.getString(offset + 10));
        entity.setMChannelDownloadUrl(cursor.isNull(offset + 11) ? null : cursor.getString(offset + 11));
        entity.setMPackageName(cursor.isNull(offset + 12) ? null : cursor.getString(offset + 12));
        entity.setMVersionCode(cursor.isNull(offset + 13) ? null : cursor.getInt(offset + 13));
        entity.setMApkPath(cursor.isNull(offset + 14) ? null : cursor.getString(offset + 14));
        entity.setWhereFrom(cursor.getInt(offset + 15));
        entity.setAverageSpeed(cursor.isNull(offset + 16) ? null : cursor.getString(offset + 16));
        entity.setRealCauseMsg(cursor.isNull(offset + 17) ? null : cursor.getString(offset + 17));
     }
    
    @Override
    protected final Long updateKeyAfterInsert(DownLoadInfo entity, long rowId) {
        entity.setMId(rowId);
        return rowId;
    }
    
    @Override
    public Long getKey(DownLoadInfo entity) {
        if(entity != null) {
            return entity.getMId();
        } else {
            return null;
        }
    }

    @Override
    public boolean hasKey(DownLoadInfo entity) {
        return entity.getMId() != null;
    }

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