package me.chyxion.tigon.model;

import java.util.List;

/**
 * @version 0.0.1
 * @since 0.0.1
 * @author Shaun Chyxion <br>
 * chyxion@163.com <br>
 * Oct 12, 2016 3:51:58 PM
 */
public class ListResult<T>
    extends ViewModel<List<T>>
    implements ListResultApi<T> {
    private static final long serialVersionUID = 1L;
    private static final String TOTAL_KEY = "total";

    /**
     * default constructor
     */
    public ListResult() {
    }
    /**
     * @param total
     * @param data
     */
    public ListResult(List<T> data, Integer total) {
        super(data);
        setAttr(TOTAL_KEY, total);
    }
    /**
     * @param total
     * @param data
     */
    public ListResult(List<T> data, int total) {
        super(data);
        setAttr(TOTAL_KEY, total);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public Integer getTotal() {
        return getAttr(TOTAL_KEY);
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ListResultApi<T> setTotal(Integer total) {
        setAttr(TOTAL_KEY, total);
        return this;
    }
    /**
     * {@inheritDoc}
     */
    @Override
    public ListResultApi<T> setTotal(int total) {
        setAttr(TOTAL_KEY, total);
        return this;
    }
}
