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

// @formatter:off
import java.util.Date;

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.datashare.provider.base.AbstractSelection;

/**
 * Selection for the {@code session} table.
 */
@SuppressWarnings({"unused", "WeakerAccess", "Recycle"})
public class SessionSelection extends AbstractSelection<SessionSelection> {
    @Override
    protected Uri baseUri() {
        return SessionColumns.CONTENT_URI;
    }

    /**
     * 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 SessionCursor} object, which is positioned before the first entry, or null.
     */
    public SessionCursor query(ContentResolver contentResolver, String[] projection) {
        Cursor cursor = contentResolver.query(uri(), projection, sel(), args(), order());
        if (cursor == null) return null;
        return new SessionCursor(cursor);
    }

    /**
     * Equivalent of calling {@code query(contentResolver, null)}.
     */
    public SessionCursor 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 SessionCursor} object, which is positioned before the first entry, or null.
     */
    public SessionCursor query(Context context, String[] projection) {
        Cursor cursor = context.getContentResolver().query(uri(), projection, sel(), args(), order());
        if (cursor == null) return null;
        return new SessionCursor(cursor);
    }

    /**
     * Equivalent of calling {@code query(context, null)}.
     */
    public SessionCursor 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 SessionCursor(super.loadInBackground());
            }
        };
    }


    public SessionSelection id(long... value) {
        addEquals("session." + SessionColumns._ID, toObjectArray(value));
        return this;
    }

    public SessionSelection idNot(long... value) {
        addNotEquals("session." + SessionColumns._ID, toObjectArray(value));
        return this;
    }

    public SessionSelection orderById(boolean desc) {
        orderBy("session." + SessionColumns._ID, desc);
        return this;
    }

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

    public SessionSelection account(String... value) {
        addEquals(SessionColumns.ACCOUNT, value);
        return this;
    }

    public SessionSelection accountNot(String... value) {
        addNotEquals(SessionColumns.ACCOUNT, value);
        return this;
    }

    public SessionSelection accountLike(String... value) {
        addLike(SessionColumns.ACCOUNT, value);
        return this;
    }

    public SessionSelection accountContains(String... value) {
        addContains(SessionColumns.ACCOUNT, value);
        return this;
    }

    public SessionSelection accountStartsWith(String... value) {
        addStartsWith(SessionColumns.ACCOUNT, value);
        return this;
    }

    public SessionSelection accountEndsWith(String... value) {
        addEndsWith(SessionColumns.ACCOUNT, value);
        return this;
    }

    public SessionSelection orderByAccount(boolean desc) {
        orderBy(SessionColumns.ACCOUNT, desc);
        return this;
    }

    public SessionSelection orderByAccount() {
        orderBy(SessionColumns.ACCOUNT, false);
        return this;
    }

    public SessionSelection openId(String... value) {
        addEquals(SessionColumns.OPEN_ID, value);
        return this;
    }

    public SessionSelection openIdNot(String... value) {
        addNotEquals(SessionColumns.OPEN_ID, value);
        return this;
    }

    public SessionSelection openIdLike(String... value) {
        addLike(SessionColumns.OPEN_ID, value);
        return this;
    }

    public SessionSelection openIdContains(String... value) {
        addContains(SessionColumns.OPEN_ID, value);
        return this;
    }

    public SessionSelection openIdStartsWith(String... value) {
        addStartsWith(SessionColumns.OPEN_ID, value);
        return this;
    }

    public SessionSelection openIdEndsWith(String... value) {
        addEndsWith(SessionColumns.OPEN_ID, value);
        return this;
    }

    public SessionSelection orderByOpenId(boolean desc) {
        orderBy(SessionColumns.OPEN_ID, desc);
        return this;
    }

    public SessionSelection orderByOpenId() {
        orderBy(SessionColumns.OPEN_ID, false);
        return this;
    }

    public SessionSelection updateTime(long... value) {
        addEquals(SessionColumns.UPDATE_TIME, toObjectArray(value));
        return this;
    }

    public SessionSelection updateTimeNot(long... value) {
        addNotEquals(SessionColumns.UPDATE_TIME, toObjectArray(value));
        return this;
    }

    public SessionSelection updateTimeGt(long value) {
        addGreaterThan(SessionColumns.UPDATE_TIME, value);
        return this;
    }

    public SessionSelection updateTimeGtEq(long value) {
        addGreaterThanOrEquals(SessionColumns.UPDATE_TIME, value);
        return this;
    }

    public SessionSelection updateTimeLt(long value) {
        addLessThan(SessionColumns.UPDATE_TIME, value);
        return this;
    }

    public SessionSelection updateTimeLtEq(long value) {
        addLessThanOrEquals(SessionColumns.UPDATE_TIME, value);
        return this;
    }

    public SessionSelection orderByUpdateTime(boolean desc) {
        orderBy(SessionColumns.UPDATE_TIME, desc);
        return this;
    }

    public SessionSelection orderByUpdateTime() {
        orderBy(SessionColumns.UPDATE_TIME, false);
        return this;
    }

    public SessionSelection token(String... value) {
        addEquals(SessionColumns.TOKEN, value);
        return this;
    }

    public SessionSelection tokenNot(String... value) {
        addNotEquals(SessionColumns.TOKEN, value);
        return this;
    }

    public SessionSelection tokenLike(String... value) {
        addLike(SessionColumns.TOKEN, value);
        return this;
    }

    public SessionSelection tokenContains(String... value) {
        addContains(SessionColumns.TOKEN, value);
        return this;
    }

    public SessionSelection tokenStartsWith(String... value) {
        addStartsWith(SessionColumns.TOKEN, value);
        return this;
    }

    public SessionSelection tokenEndsWith(String... value) {
        addEndsWith(SessionColumns.TOKEN, value);
        return this;
    }

    public SessionSelection orderByToken(boolean desc) {
        orderBy(SessionColumns.TOKEN, desc);
        return this;
    }

    public SessionSelection orderByToken() {
        orderBy(SessionColumns.TOKEN, false);
        return this;
    }

    public SessionSelection uid(Integer... value) {
        addEquals(SessionColumns.UID, value);
        return this;
    }

    public SessionSelection uidNot(Integer... value) {
        addNotEquals(SessionColumns.UID, value);
        return this;
    }

    public SessionSelection uidGt(int value) {
        addGreaterThan(SessionColumns.UID, value);
        return this;
    }

    public SessionSelection uidGtEq(int value) {
        addGreaterThanOrEquals(SessionColumns.UID, value);
        return this;
    }

    public SessionSelection uidLt(int value) {
        addLessThan(SessionColumns.UID, value);
        return this;
    }

    public SessionSelection uidLtEq(int value) {
        addLessThanOrEquals(SessionColumns.UID, value);
        return this;
    }

    public SessionSelection orderByUid(boolean desc) {
        orderBy(SessionColumns.UID, desc);
        return this;
    }

    public SessionSelection orderByUid() {
        orderBy(SessionColumns.UID, false);
        return this;
    }

    public SessionSelection hash(Integer... value) {
        addEquals(SessionColumns.HASH, value);
        return this;
    }

    public SessionSelection hashNot(Integer... value) {
        addNotEquals(SessionColumns.HASH, value);
        return this;
    }

    public SessionSelection hashGt(int value) {
        addGreaterThan(SessionColumns.HASH, value);
        return this;
    }

    public SessionSelection hashGtEq(int value) {
        addGreaterThanOrEquals(SessionColumns.HASH, value);
        return this;
    }

    public SessionSelection hashLt(int value) {
        addLessThan(SessionColumns.HASH, value);
        return this;
    }

    public SessionSelection hashLtEq(int value) {
        addLessThanOrEquals(SessionColumns.HASH, value);
        return this;
    }

    public SessionSelection orderByHash(boolean desc) {
        orderBy(SessionColumns.HASH, desc);
        return this;
    }

    public SessionSelection orderByHash() {
        orderBy(SessionColumns.HASH, false);
        return this;
    }
}
