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

// @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 records} table.
 */
@SuppressWarnings({"WeakerAccess", "unused", "UnnecessaryLocalVariable"})
public class RecordsCursor extends AbstractCursor implements RecordsModel {
    public RecordsCursor(Cursor cursor) {
        super(cursor);
    }

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

    /**
     * update create_time of this records.
     */
    @Override
    public long getCreateTime() {
        Long res = getLongOrNull(RecordsColumns.CREATE_TIME);
        if (res == null)
            throw new NullPointerException("The value of 'create_time' in the database was null, which is not allowed according to the model definition");
        return res;
    }

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