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

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

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

import com.kfzs.duanduan.datashare.provider.base.AbstractCursor;

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

    /**
     * Primary key.
     */
    @Override
    public long getId() {
        Long res = getLongOrNull(SessionColumns._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;
    }

    /**
     * account of this session. For instance, John.
     * Cannot be {@code null}.
     */
    @NonNull
    @Override
    public String getAccount() {
        String res = getStringOrNull(SessionColumns.ACCOUNT);
        if (res == null)
            throw new NullPointerException("The value of 'account' in the database was null, which is not allowed according to the model definition");
        return res;
    }

    /**
     * open_id of this session. For instance, John.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getOpenId() {
        String res = getStringOrNull(SessionColumns.OPEN_ID);
        return res;
    }

    /**
     * update time of this session.
     */
    @Override
    public long getUpdateTime() {
        Long res = getLongOrNull(SessionColumns.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;
    }

    /**
     * token of this session.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public String getToken() {
        String res = getStringOrNull(SessionColumns.TOKEN);
        return res;
    }

    /**
     * uid at user of this session.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public Integer getUid() {
        Integer res = getIntegerOrNull(SessionColumns.UID);
        return res;
    }

    /**
     * data hash save of this session.
     * Can be {@code null}.
     */
    @Nullable
    @Override
    public Integer getHash() {
        Integer res = getIntegerOrNull(SessionColumns.HASH);
        return res;
    }
}
