class DenseLocalDateDoubleTimeSeries implements ImmutableBean, LocalDateDoubleTimeSeries, Serializable {

  static LocalDateDoubleTimeSeries of(
      LocalDate startDate,
      LocalDate endDate,
      Stream<LocalDateDoublePoint> values,
      DenseTimeSeriesCalculation dateCalculation) {

    double[] points = new double[dateCalculation.calculatePosition(startDate, endDate) + 1];
    Arrays.fill(points, Double.NaN);
    int size = 1;
    for (LocalDateDoublePoint pt : in(values)) {
      points[dateCalculation.calculatePosition(startDate, pt.getDate())] = pt.getValue();
      size++;
    }
    return new DenseLocalDateDoubleTimeSeries(startDate, points, dateCalculation, true, size);
  }

  private  DenseLocalDateDoubleTimeSeries(
      LocalDate startDate,
      double[] points,
      DenseTimeSeriesCalculation dateCalculation,
      boolean trusted,
      int size);
  @ImmutableConstructor private  DenseLocalDateDoubleTimeSeries(
      LocalDate startDate,
      double[] points,
      DenseTimeSeriesCalculation dateCalculation);

}