package io.github.jjsimas.chart2d;

import java.util.List;
import java.util.Objects;

public record PieChartModel(
  String title,
  List<PieSlice> slices,
  PieChartOptions options,
  ChartTheme theme
) {

  public PieChartModel {
    title = Objects.requireNonNullElse(title, "");
    slices = List.copyOf(Objects.requireNonNull(slices, "slices"));
    options = Objects.requireNonNullElse(options, PieChartOptions.defaults());
    theme = Objects.requireNonNullElse(theme, ChartTheme.defaults());
    if (slices.isEmpty()) {
      throw new IllegalArgumentException("slices must not be empty");
    }
  }
}
