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

// @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.datashare.provider.base.AbstractContentValues;

/**
 * Content values wrapper for the {@code records} table.
 */
@SuppressWarnings({"ConstantConditions", "unused"})
public class RecordsContentValues extends AbstractContentValues {
    @Override
    public Uri uri() {
        return RecordsColumns.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 RecordsSelection 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 RecordsSelection where) {
        return context.getContentResolver().update(uri(), values(), where == null ? null : where.sel(), where == null ? null : where.args());
    }

    /**
     * update create_time of this records.
     */
    public RecordsContentValues putCreateTime(long value) {
        mContentValues.put(RecordsColumns.CREATE_TIME, value);
        return this;
    }


    /**
     * name of this records.
     */
    public RecordsContentValues putName(@NonNull String value) {
        if (value == null) throw new IllegalArgumentException("name must not be null");
        mContentValues.put(RecordsColumns.NAME, value);
        return this;
    }

}
