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

// @formatter:off
import com.kfzs.duanduan.datashare.provider.base.BaseModel;

import java.util.Date;

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

/**
 * A records info which is part of a team.
 */
@SuppressWarnings({"WeakerAccess", "unused", "ConstantConditions"})
public class RecordsBean implements RecordsModel {
    private long mId;
    private long mCreateTime;
    private String mName;

    /**
     * Primary key.
     */
    @Override
    public long getId() {
        return mId;
    }

    /**
     * Primary key.
     */
    public void setId(long id) {
        mId = id;
    }

    /**
     * update create_time of this records.
     */
    @Override
    public long getCreateTime() {
        return mCreateTime;
    }

    /**
     * update create_time of this records.
     */
    public void setCreateTime(long createTime) {
        mCreateTime = createTime;
    }

    /**
     * name of this records.
     * Cannot be {@code null}.
     */
    @NonNull
    @Override
    public String getName() {
        return mName;
    }

    /**
     * name of this records.
     * Must not be {@code null}.
     */
    public void setName(@NonNull String name) {
        if (name == null) throw new IllegalArgumentException("name must not be null");
        mName = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        RecordsBean bean = (RecordsBean) o;
        return mId == bean.mId;
    }

    @Override
    public int hashCode() {
        return (int) (mId ^ (mId >>> 32));
    }

    /**
     * Instantiate a new RecordsBean with specified values.
     */
    @NonNull
    public static RecordsBean newInstance(long id, long createTime, @NonNull String name) {
        if (name == null) throw new IllegalArgumentException("name must not be null");
        RecordsBean res = new RecordsBean();
        res.mId = id;
        res.mCreateTime = createTime;
        res.mName = name;
        return res;
    }

    /**
     * Instantiate a new RecordsBean with all the values copied from the given model.
     */
    @NonNull
    public static RecordsBean copy(@NonNull RecordsModel from) {
        RecordsBean res = new RecordsBean();
        res.mId = from.getId();
        res.mCreateTime = from.getCreateTime();
        res.mName = from.getName();
        return res;
    }

    public static class Builder {
        private RecordsBean mRes = new RecordsBean();

        /**
         * Primary key.
         */
        public Builder id(long id) {
            mRes.mId = id;
            return this;
        }

        /**
         * update create_time of this records.
         */
        public Builder createTime(long createTime) {
            mRes.mCreateTime = createTime;
            return this;
        }

        /**
         * name of this records.
         * Must not be {@code null}.
         */
        public Builder name(@NonNull String name) {
            if (name == null) throw new IllegalArgumentException("name must not be null");
            mRes.mName = name;
            return this;
        }

        /**
         * Get a new RecordsBean built with the given values.
         */
        public RecordsBean build() {
            if (mRes.mName == null) throw new IllegalArgumentException("name must not be null");
            return mRes;
        }
    }

    public static Builder newBuilder() {
        return new Builder();
    }
}
