using System;

namespace MultiWheelC.TrajectoryPlanning.EMPlanner;

/// <summary>Immutable completion record for one rolling planning cycle.</summary>
public sealed class PlanningCycleResult
{
    public PlanningCycleResult(long version, PlanningCycleIdentity identity, EmPlanningResult result, bool published,
        string diagnostic)
    {
        if (version <= 0)
            throw new ArgumentOutOfRangeException(nameof(version));
        Version = version;
        Identity = identity ?? throw new ArgumentNullException(nameof(identity));
        Result = result ?? throw new ArgumentNullException(nameof(result));
        Published = published;
        Diagnostic = diagnostic ?? string.Empty;
    }

    public long Version { get; }

    public PlanningCycleIdentity Identity { get; }

    public EmPlanningResult Result { get; }

    public bool Published { get; }

    public string Diagnostic { get; }

    internal PlanningCycleResult WithDiagnostic(string diagnostic)
    {
        return new PlanningCycleResult(Version, Identity, Result, Published, diagnostic);
    }
}
