using System; using System.Collections.Generic; using System.Collections.ObjectModel; namespace MultiWheelC.TrajectoryPlanning.EMPlanner; public sealed class EmTrajectory { public EmTrajectory(EmTrajectoryMetadata metadata, IReadOnlyList points) { if (metadata == null) throw new ArgumentNullException(nameof(metadata)); if (points == null) throw new ArgumentNullException(nameof(points)); if (points.Count == 0) throw new ArgumentException("A published trajectory requires at least one point.", nameof(points)); var copy = new List(points.Count); for (int index = 0; index < points.Count; index++) { if (points[index] == null) throw new ArgumentException("Trajectory points cannot contain null values.", nameof(points)); copy.Add(points[index]); } Metadata = metadata; Points = new ReadOnlyCollection(copy); } public EmTrajectoryMetadata Metadata { get; } public IReadOnlyList Points { get; } }