using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace MultiWheelC.TrajectoryPlanning.EMPlanner;

/// <summary>Immutable reconstructed lateral path, marked only after independent validation.</summary>
public sealed class LateralPath
{
    public LateralPath(IReadOnlyList<LateralPathPoint> points, bool independentlyValidated)
    {
        if (points == null)
            throw new ArgumentNullException(nameof(points));

        var copy = new List<LateralPathPoint>(points.Count);
        for (int index = 0; index < points.Count; index++)
        {
            if (points[index] == null)
                throw new ArgumentException("Lateral path points cannot contain null values.", nameof(points));
            copy.Add(points[index]);
        }
        Points = new ReadOnlyCollection<LateralPathPoint>(copy);
        IsIndependentlyValidated = independentlyValidated;
    }

    public IReadOnlyList<LateralPathPoint> Points { get; }

    public bool IsIndependentlyValidated { get; }
}
