package com.kfzs.duanduan.datashare.provider.downloadtask;

// @formatter:off

import android.content.Context;
import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.support.v4.content.CursorLoader;

import com.kfzs.duanduan.data.graph.provider.KFZSProvider;
import com.kfzs.duanduan.datashare.provider.base.AbstractSelection;
import com.kfzs.duanduan.datashare.provider.download.DownLoadInfoDao;

/**
 * Selection for the {@code downloadtask} table.
 */
@SuppressWarnings({"unused", "WeakerAccess", "Recycle"})
public class DownloadtaskSelection extends AbstractSelection<DownloadtaskSelection> {
    @Override
    protected Uri baseUri() {
        return Uri.parse(KFZSProvider.CONTENT_URI_BASE+"/"+ DownLoadInfoDao.TABLENAME);
    }

    /**
     * Query the given content resolver using this selection.
     *
     * @param contentResolver The content resolver to query.
     * @param projection A list of which columns to return. Passing null will return all columns, which is inefficient.
     * @return A {@code DownloadtaskCursor} object, which is positioned before the first entry, or null.
     */
    public DownloadtaskCursor query(ContentResolver contentResolver, String[] projection) {
        Cursor cursor = contentResolver.query(uri(), projection, sel(), args(), order());
        if (cursor == null) return null;
        return new DownloadtaskCursor(cursor);
    }

    /**
     * Equivalent of calling {@code query(contentResolver, null)}.
     */
    public DownloadtaskCursor query(ContentResolver contentResolver) {
        return query(contentResolver, null);
    }

    /**
     * Query the given content resolver using this selection.
     *
     * @param context The context to use for the query.
     * @param projection A list of which columns to return. Passing null will return all columns, which is inefficient.
     * @return A {@code DownloadtaskCursor} object, which is positioned before the first entry, or null.
     */
    public DownloadtaskCursor query(Context context, String[] projection) {
        Cursor cursor = context.getContentResolver().query(uri(), projection, sel(), args(), order());
        if (cursor == null) return null;
        return new DownloadtaskCursor(cursor);
    }

    /**
     * Equivalent of calling {@code query(context, null)}.
     */
    public DownloadtaskCursor query(Context context) {
        return query(context, null);
    }


    /**
     * {@inheritDoc}
     */
    @Override
    public CursorLoader getCursorLoader(Context context, String[] projection) {
        return new CursorLoader(context, uri(), projection, sel(), args(), order()) {
            @Override
            public Cursor loadInBackground() {
                return new DownloadtaskCursor(super.loadInBackground());
            }
        };
    }


    public DownloadtaskSelection id(long... value) {
        addEquals("downloadtask." + DownloadtaskColumns._ID, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection idNot(long... value) {
        addNotEquals("downloadtask." + DownloadtaskColumns._ID, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection orderById(boolean desc) {
        orderBy("downloadtask." + DownloadtaskColumns._ID, desc);
        return this;
    }

    public DownloadtaskSelection orderById() {
        return orderById(false);
    }

    public DownloadtaskSelection createTime(long... value) {
        addEquals(DownloadtaskColumns.CREATE_TIME, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection createTimeNot(long... value) {
        addNotEquals(DownloadtaskColumns.CREATE_TIME, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection createTimeGt(long value) {
        addGreaterThan(DownloadtaskColumns.CREATE_TIME, value);
        return this;
    }

    public DownloadtaskSelection createTimeGtEq(long value) {
        addGreaterThanOrEquals(DownloadtaskColumns.CREATE_TIME, value);
        return this;
    }

    public DownloadtaskSelection createTimeLt(long value) {
        addLessThan(DownloadtaskColumns.CREATE_TIME, value);
        return this;
    }

    public DownloadtaskSelection createTimeLtEq(long value) {
        addLessThanOrEquals(DownloadtaskColumns.CREATE_TIME, value);
        return this;
    }

    public DownloadtaskSelection orderByCreateTime(boolean desc) {
        orderBy(DownloadtaskColumns.CREATE_TIME, desc);
        return this;
    }

    public DownloadtaskSelection orderByCreateTime() {
        orderBy(DownloadtaskColumns.CREATE_TIME, false);
        return this;
    }

    public DownloadtaskSelection downloadTaskId(Integer... value) {
        addEquals(DownloadtaskColumns.DOWNLOAD_TASK_ID, value);
        return this;
    }

    public DownloadtaskSelection downloadTaskIdNot(Integer... value) {
        addNotEquals(DownloadtaskColumns.DOWNLOAD_TASK_ID, value);
        return this;
    }

    public DownloadtaskSelection downloadTaskIdGt(int value) {
        addGreaterThan(DownloadtaskColumns.DOWNLOAD_TASK_ID, value);
        return this;
    }

    public DownloadtaskSelection downloadTaskIdGtEq(int value) {
        addGreaterThanOrEquals(DownloadtaskColumns.DOWNLOAD_TASK_ID, value);
        return this;
    }

    public DownloadtaskSelection downloadTaskIdLt(int value) {
        addLessThan(DownloadtaskColumns.DOWNLOAD_TASK_ID, value);
        return this;
    }

    public DownloadtaskSelection downloadTaskIdLtEq(int value) {
        addLessThanOrEquals(DownloadtaskColumns.DOWNLOAD_TASK_ID, value);
        return this;
    }

    public DownloadtaskSelection orderByDownloadTaskId(boolean desc) {
        orderBy(DownloadtaskColumns.DOWNLOAD_TASK_ID, desc);
        return this;
    }

    public DownloadtaskSelection orderByDownloadTaskId() {
        orderBy(DownloadtaskColumns.DOWNLOAD_TASK_ID, false);
        return this;
    }

    public DownloadtaskSelection gameName(String... value) {
        addEquals(DownloadtaskColumns.GAME_NAME, value);
        return this;
    }

    public DownloadtaskSelection gameNameNot(String... value) {
        addNotEquals(DownloadtaskColumns.GAME_NAME, value);
        return this;
    }

    public DownloadtaskSelection gameNameLike(String... value) {
        addLike(DownloadtaskColumns.GAME_NAME, value);
        return this;
    }

    public DownloadtaskSelection gameNameContains(String... value) {
        addContains(DownloadtaskColumns.GAME_NAME, value);
        return this;
    }

    public DownloadtaskSelection gameNameStartsWith(String... value) {
        addStartsWith(DownloadtaskColumns.GAME_NAME, value);
        return this;
    }

    public DownloadtaskSelection gameNameEndsWith(String... value) {
        addEndsWith(DownloadtaskColumns.GAME_NAME, value);
        return this;
    }

    public DownloadtaskSelection orderByGameName(boolean desc) {
        orderBy(DownloadtaskColumns.GAME_NAME, desc);
        return this;
    }

    public DownloadtaskSelection orderByGameName() {
        orderBy(DownloadtaskColumns.GAME_NAME, false);
        return this;
    }

    public DownloadtaskSelection iconUrl(String... value) {
        addEquals(DownloadtaskColumns.ICON_URL, value);
        return this;
    }

    public DownloadtaskSelection iconUrlNot(String... value) {
        addNotEquals(DownloadtaskColumns.ICON_URL, value);
        return this;
    }

    public DownloadtaskSelection iconUrlLike(String... value) {
        addLike(DownloadtaskColumns.ICON_URL, value);
        return this;
    }

    public DownloadtaskSelection iconUrlContains(String... value) {
        addContains(DownloadtaskColumns.ICON_URL, value);
        return this;
    }

    public DownloadtaskSelection iconUrlStartsWith(String... value) {
        addStartsWith(DownloadtaskColumns.ICON_URL, value);
        return this;
    }

    public DownloadtaskSelection iconUrlEndsWith(String... value) {
        addEndsWith(DownloadtaskColumns.ICON_URL, value);
        return this;
    }

    public DownloadtaskSelection orderByIconUrl(boolean desc) {
        orderBy(DownloadtaskColumns.ICON_URL, desc);
        return this;
    }

    public DownloadtaskSelection orderByIconUrl() {
        orderBy(DownloadtaskColumns.ICON_URL, false);
        return this;
    }

    public DownloadtaskSelection percent(Integer... value) {
        addEquals(DownloadtaskColumns.PERCENT, value);
        return this;
    }

    public DownloadtaskSelection percentNot(Integer... value) {
        addNotEquals(DownloadtaskColumns.PERCENT, value);
        return this;
    }

    public DownloadtaskSelection percentGt(int value) {
        addGreaterThan(DownloadtaskColumns.PERCENT, value);
        return this;
    }

    public DownloadtaskSelection percentGtEq(int value) {
        addGreaterThanOrEquals(DownloadtaskColumns.PERCENT, value);
        return this;
    }

    public DownloadtaskSelection percentLt(int value) {
        addLessThan(DownloadtaskColumns.PERCENT, value);
        return this;
    }

    public DownloadtaskSelection percentLtEq(int value) {
        addLessThanOrEquals(DownloadtaskColumns.PERCENT, value);
        return this;
    }

    public DownloadtaskSelection orderByPercent(boolean desc) {
        orderBy(DownloadtaskColumns.PERCENT, desc);
        return this;
    }

    public DownloadtaskSelection orderByPercent() {
        orderBy(DownloadtaskColumns.PERCENT, false);
        return this;
    }

    public DownloadtaskSelection downloadedSize(Double... value) {
        addEquals(DownloadtaskColumns.DOWNLOADED_SIZE, value);
        return this;
    }

    public DownloadtaskSelection downloadedSizeNot(Double... value) {
        addNotEquals(DownloadtaskColumns.DOWNLOADED_SIZE, value);
        return this;
    }

    public DownloadtaskSelection downloadedSizeGt(double value) {
        addGreaterThan(DownloadtaskColumns.DOWNLOADED_SIZE, value);
        return this;
    }

    public DownloadtaskSelection downloadedSizeGtEq(double value) {
        addGreaterThanOrEquals(DownloadtaskColumns.DOWNLOADED_SIZE, value);
        return this;
    }

    public DownloadtaskSelection downloadedSizeLt(double value) {
        addLessThan(DownloadtaskColumns.DOWNLOADED_SIZE, value);
        return this;
    }

    public DownloadtaskSelection downloadedSizeLtEq(double value) {
        addLessThanOrEquals(DownloadtaskColumns.DOWNLOADED_SIZE, value);
        return this;
    }

    public DownloadtaskSelection orderByDownloadedSize(boolean desc) {
        orderBy(DownloadtaskColumns.DOWNLOADED_SIZE, desc);
        return this;
    }

    public DownloadtaskSelection orderByDownloadedSize() {
        orderBy(DownloadtaskColumns.DOWNLOADED_SIZE, false);
        return this;
    }

    public DownloadtaskSelection totalSize(Double... value) {
        addEquals(DownloadtaskColumns.TOTAL_SIZE, value);
        return this;
    }

    public DownloadtaskSelection totalSizeNot(Double... value) {
        addNotEquals(DownloadtaskColumns.TOTAL_SIZE, value);
        return this;
    }

    public DownloadtaskSelection totalSizeGt(double value) {
        addGreaterThan(DownloadtaskColumns.TOTAL_SIZE, value);
        return this;
    }

    public DownloadtaskSelection totalSizeGtEq(double value) {
        addGreaterThanOrEquals(DownloadtaskColumns.TOTAL_SIZE, value);
        return this;
    }

    public DownloadtaskSelection totalSizeLt(double value) {
        addLessThan(DownloadtaskColumns.TOTAL_SIZE, value);
        return this;
    }

    public DownloadtaskSelection totalSizeLtEq(double value) {
        addLessThanOrEquals(DownloadtaskColumns.TOTAL_SIZE, value);
        return this;
    }

    public DownloadtaskSelection orderByTotalSize(boolean desc) {
        orderBy(DownloadtaskColumns.TOTAL_SIZE, desc);
        return this;
    }

    public DownloadtaskSelection orderByTotalSize() {
        orderBy(DownloadtaskColumns.TOTAL_SIZE, false);
        return this;
    }

    public DownloadtaskSelection status(int... value) {
        addEquals(DownloadtaskColumns.STATUS, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection statusNot(int... value) {
        addNotEquals(DownloadtaskColumns.STATUS, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection statusGt(int value) {
        addGreaterThan(DownloadtaskColumns.STATUS, value);
        return this;
    }

    public DownloadtaskSelection statusGtEq(int value) {
        addGreaterThanOrEquals(DownloadtaskColumns.STATUS, value);
        return this;
    }

    public DownloadtaskSelection statusLt(int value) {
        addLessThan(DownloadtaskColumns.STATUS, value);
        return this;
    }

    public DownloadtaskSelection statusLtEq(int value) {
        addLessThanOrEquals(DownloadtaskColumns.STATUS, value);
        return this;
    }

    public DownloadtaskSelection orderByStatus(boolean desc) {
        orderBy(DownloadtaskColumns.STATUS, desc);
        return this;
    }

    public DownloadtaskSelection orderByStatus() {
        orderBy(DownloadtaskColumns.STATUS, false);
        return this;
    }

    public DownloadtaskSelection downloadUrl(String... value) {
        addEquals(DownloadtaskColumns.DOWNLOAD_URL, value);
        return this;
    }

    public DownloadtaskSelection downloadUrlNot(String... value) {
        addNotEquals(DownloadtaskColumns.DOWNLOAD_URL, value);
        return this;
    }

    public DownloadtaskSelection downloadUrlLike(String... value) {
        addLike(DownloadtaskColumns.DOWNLOAD_URL, value);
        return this;
    }

    public DownloadtaskSelection downloadUrlContains(String... value) {
        addContains(DownloadtaskColumns.DOWNLOAD_URL, value);
        return this;
    }

    public DownloadtaskSelection downloadUrlStartsWith(String... value) {
        addStartsWith(DownloadtaskColumns.DOWNLOAD_URL, value);
        return this;
    }

    public DownloadtaskSelection downloadUrlEndsWith(String... value) {
        addEndsWith(DownloadtaskColumns.DOWNLOAD_URL, value);
        return this;
    }

    public DownloadtaskSelection orderByDownloadUrl(boolean desc) {
        orderBy(DownloadtaskColumns.DOWNLOAD_URL, desc);
        return this;
    }

    public DownloadtaskSelection orderByDownloadUrl() {
        orderBy(DownloadtaskColumns.DOWNLOAD_URL, false);
        return this;
    }

    public DownloadtaskSelection packageName(String... value) {
        addEquals(DownloadtaskColumns.PACKAGE_NAME, value);
        return this;
    }

    public DownloadtaskSelection packageNameNot(String... value) {
        addNotEquals(DownloadtaskColumns.PACKAGE_NAME, value);
        return this;
    }

    public DownloadtaskSelection packageNameLike(String... value) {
        addLike(DownloadtaskColumns.PACKAGE_NAME, value);
        return this;
    }

    public DownloadtaskSelection packageNameContains(String... value) {
        addContains(DownloadtaskColumns.PACKAGE_NAME, value);
        return this;
    }

    public DownloadtaskSelection packageNameStartsWith(String... value) {
        addStartsWith(DownloadtaskColumns.PACKAGE_NAME, value);
        return this;
    }

    public DownloadtaskSelection packageNameEndsWith(String... value) {
        addEndsWith(DownloadtaskColumns.PACKAGE_NAME, value);
        return this;
    }

    public DownloadtaskSelection orderByPackageName(boolean desc) {
        orderBy(DownloadtaskColumns.PACKAGE_NAME, desc);
        return this;
    }

    public DownloadtaskSelection orderByPackageName() {
        orderBy(DownloadtaskColumns.PACKAGE_NAME, false);
        return this;
    }

    public DownloadtaskSelection versionCode(int... value) {
        addEquals(DownloadtaskColumns.VERSION_CODE, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection versionCodeNot(int... value) {
        addNotEquals(DownloadtaskColumns.VERSION_CODE, toObjectArray(value));
        return this;
    }

    public DownloadtaskSelection versionCodeGt(int value) {
        addGreaterThan(DownloadtaskColumns.VERSION_CODE, value);
        return this;
    }

    public DownloadtaskSelection versionCodeGtEq(int value) {
        addGreaterThanOrEquals(DownloadtaskColumns.VERSION_CODE, value);
        return this;
    }

    public DownloadtaskSelection versionCodeLt(int value) {
        addLessThan(DownloadtaskColumns.VERSION_CODE, value);
        return this;
    }

    public DownloadtaskSelection versionCodeLtEq(int value) {
        addLessThanOrEquals(DownloadtaskColumns.VERSION_CODE, value);
        return this;
    }

    public DownloadtaskSelection orderByVersionCode(boolean desc) {
        orderBy(DownloadtaskColumns.VERSION_CODE, desc);
        return this;
    }

    public DownloadtaskSelection orderByVersionCode() {
        orderBy(DownloadtaskColumns.VERSION_CODE, false);
        return this;
    }

    public DownloadtaskSelection apkPath(String... value) {
        addEquals(DownloadtaskColumns.APK_PATH, value);
        return this;
    }

    public DownloadtaskSelection apkPathNot(String... value) {
        addNotEquals(DownloadtaskColumns.APK_PATH, value);
        return this;
    }

    public DownloadtaskSelection apkPathLike(String... value) {
        addLike(DownloadtaskColumns.APK_PATH, value);
        return this;
    }

    public DownloadtaskSelection apkPathContains(String... value) {
        addContains(DownloadtaskColumns.APK_PATH, value);
        return this;
    }

    public DownloadtaskSelection apkPathStartsWith(String... value) {
        addStartsWith(DownloadtaskColumns.APK_PATH, value);
        return this;
    }

    public DownloadtaskSelection apkPathEndsWith(String... value) {
        addEndsWith(DownloadtaskColumns.APK_PATH, value);
        return this;
    }

    public DownloadtaskSelection orderByApkPath(boolean desc) {
        orderBy(DownloadtaskColumns.APK_PATH, desc);
        return this;
    }

    public DownloadtaskSelection orderByApkPath() {
        orderBy(DownloadtaskColumns.APK_PATH, false);
        return this;
    }
}
