package com.kfzs.duanduan.data.graph.provider.user;

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

import android.content.Context;
import android.content.ContentResolver;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.kfzs.duanduan.data.graph.provider.base.AbstractContentValues;

/**
 * Content values wrapper for the {@code user} table.
 */
@SuppressWarnings({"ConstantConditions", "unused"})
public class UserContentValues extends AbstractContentValues {
    @Override
    public Uri uri() {
        return UserColumns.CONTENT_URI;
    }

    /**
     * Update row(s) using the values stored by this object and the given selection.
     *
     * @param contentResolver The content resolver to use.
     * @param where The selection to use (can be {@code null}).
     */
    public int update(ContentResolver contentResolver, @Nullable UserSelection where) {
        return contentResolver.update(uri(), values(), where == null ? null : where.sel(), where == null ? null : where.args());
    }

    /**
     * Update row(s) using the values stored by this object and the given selection.
     *
     * @param context The context to use.
     * @param where The selection to use (can be {@code null}).
     */
    public int update(Context context, @Nullable UserSelection where) {
        return context.getContentResolver().update(uri(), values(), where == null ? null : where.sel(), where == null ? null : where.args());
    }

    /**
     * uid at user of this user.
     */
    public UserContentValues putUid(int value) {
        mContentValues.put(UserColumns.UID, value);
        return this;
    }


    /**
     * user_name of this user.
     */
    public UserContentValues putUserName(@NonNull String value) {
        if (value == null) throw new IllegalArgumentException("userName must not be null");
        mContentValues.put(UserColumns.USER_NAME, value);
        return this;
    }


    /**
     * update time of this user.
     */
    public UserContentValues putUpdateTime(long value) {
        mContentValues.put(UserColumns.UPDATE_TIME, value);
        return this;
    }


    /**
     * phone of this user.
     */
    public UserContentValues putPhone(@Nullable String value) {
        mContentValues.put(UserColumns.PHONE, value);
        return this;
    }

    public UserContentValues putPhoneNull() {
        mContentValues.putNull(UserColumns.PHONE);
        return this;
    }

    /**
     * nickname of this user.
     */
    public UserContentValues putNickname(@Nullable String value) {
        mContentValues.put(UserColumns.NICKNAME, value);
        return this;
    }

    public UserContentValues putNicknameNull() {
        mContentValues.putNull(UserColumns.NICKNAME);
        return this;
    }

    /**
     * user_icon of this user.
     */
    public UserContentValues putUserIcon(@Nullable String value) {
        mContentValues.put(UserColumns.USER_ICON, value);
        return this;
    }

    public UserContentValues putUserIconNull() {
        mContentValues.putNull(UserColumns.USER_ICON);
        return this;
    }

    /**
     * avatar of this user.
     */
    public UserContentValues putAvatar(@Nullable String value) {
        mContentValues.put(UserColumns.AVATAR, value);
        return this;
    }

    public UserContentValues putAvatarNull() {
        mContentValues.putNull(UserColumns.AVATAR);
        return this;
    }

    /**
     * open_id of this user.
     */
    public UserContentValues putOpenId(@Nullable String value) {
        mContentValues.put(UserColumns.OPEN_ID, value);
        return this;
    }

    public UserContentValues putOpenIdNull() {
        mContentValues.putNull(UserColumns.OPEN_ID);
        return this;
    }

    /**
     * mail of this user.
     */
    public UserContentValues putMail(@Nullable String value) {
        mContentValues.put(UserColumns.MAIL, value);
        return this;
    }

    public UserContentValues putMailNull() {
        mContentValues.putNull(UserColumns.MAIL);
        return this;
    }

    /**
     * refresh_token of this user.
     */
    public UserContentValues putRefreshToken(@Nullable String value) {
        mContentValues.put(UserColumns.REFRESH_TOKEN, value);
        return this;
    }

    public UserContentValues putRefreshTokenNull() {
        mContentValues.putNull(UserColumns.REFRESH_TOKEN);
        return this;
    }
}
