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

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

import android.database.Cursor;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

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

/**
 * Cursor wrapper for the {@code user} table.
 */
@SuppressWarnings({"WeakerAccess", "unused", "UnnecessaryLocalVariable"})
public class UserCursor extends AbstractCursor implements UserModel {
    public UserCursor(Cursor cursor) {
        super(cursor);
    }

    /**
     * Primary key.
     */
    @Override
    public long getId() {
        Long res = getLongOrNull(UserColumns._ID);
        if (res == null)
            throw new NullPointerException("The value of '_id' in the database was null, which is not allowed according to the model definition");
        return res;
    }

    /**
     * uid at user of this user.
     */
    @Override
    public int getUid() {
        Integer res = getIntegerOrNull(UserColumns.UID);
        if (res == null)
            throw new NullPointerException("The value of 'uid' in the database was null, which is not allowed according to the model definition");
        return res;
    }

    /**
     * user_name of this user.
     * Cannot be {@code null}.
     */
    @NonNull
    @Override
    public String getUserName() {
        String res = getStringOrNull(UserColumns.USER_NAME);
        if (res == null)
            throw new NullPointerException("The value of 'user_name' in the database was null, which is not allowed according to the model definition");
        return res;
    }

    /**
     * update time of this user.
     */
    @Override
    public long getUpdateTime() {
        Long res = getLongOrNull(UserColumns.UPDATE_TIME);
        if (res == null)
            throw new NullPointerException("The value of 'update_time' in the database was null, which is not allowed according to the model definition");
        return res;
    }

    /**
     * phone of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getPhone() {
        String res = getStringOrNull(UserColumns.PHONE);
        return res;
    }

    /**
     * nickname of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getNickname() {
        String res = getStringOrNull(UserColumns.NICKNAME);
        return res;
    }

    /**
     * user_icon of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getUserIcon() {
        String res = getStringOrNull(UserColumns.USER_ICON);
        return res;
    }

    /**
     * avatar of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getAvatar() {
        String res = getStringOrNull(UserColumns.AVATAR);
        return res;
    }

    /**
     * open_id of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getOpenId() {
        String res = getStringOrNull(UserColumns.OPEN_ID);
        return res;
    }

    /**
     * mail of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getMail() {
        String res = getStringOrNull(UserColumns.MAIL);
        return res;
    }

    /**
     * refresh_token of this user.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getRefreshToken() {
        String res = getStringOrNull(UserColumns.REFRESH_TOKEN);
        return res;
    }
}
