package com.mzh.library.entity;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ReportCenter {
    private InventorySummary inventorySummary;
    private BorrowingSummary borrowingSummary;
    private List<OverdueReportRow> overdueRows = Collections.emptyList();
    private List<PopularBookReportRow> popularBooks = Collections.emptyList();

    public InventorySummary getInventorySummary() {
        return inventorySummary;
    }

    public void setInventorySummary(InventorySummary inventorySummary) {
        this.inventorySummary = inventorySummary;
    }

    public BorrowingSummary getBorrowingSummary() {
        return borrowingSummary;
    }

    public void setBorrowingSummary(BorrowingSummary borrowingSummary) {
        this.borrowingSummary = borrowingSummary;
    }

    public List<OverdueReportRow> getOverdueRows() {
        return overdueRows;
    }

    public void setOverdueRows(List<OverdueReportRow> overdueRows) {
        this.overdueRows = immutableCopy(overdueRows);
    }

    public List<PopularBookReportRow> getPopularBooks() {
        return popularBooks;
    }

    public void setPopularBooks(List<PopularBookReportRow> popularBooks) {
        this.popularBooks = immutableCopy(popularBooks);
    }

    private static <T> List<T> immutableCopy(List<T> source) {
        if (source == null || source.isEmpty()) {
            return Collections.emptyList();
        }
        return Collections.unmodifiableList(new ArrayList<>(source));
    }
}
