using adas_core.Domain.Enums; namespace adas_core.Domain.Models.GroupedObservations; /// /// Represents a field that belongs to a logical grouping, encapsulating the concept of a field within a grouped structure. /// /// /// This type is intended to model fields that are organized together as part of a group, allowing related field metadata or behavior to be handled collectively. /// /// public class GroupedField { /// /// Initializes a new default instance of the class, representing a field that aggregates related items into a single addressable group. /// /// public GroupedField() { } /// /// Initializes a new instance of , which represents a configurable field for grouped observations with identifiers, scheduling offsets, and result selection. /// Null collection parameters are normalized to empty lists, and defaults to a list containing when omitted. /// /// The primary identifier of the field, or null when only the collection is used. /// The alternative identifiers for the field; when null, an empty is stored. /// The grouping key that associates the field with a logical group, or null if unspecified. /// The list of schedule offsets applied to the field; when null, an empty is stored. /// The maximum number of observations retained for the field. /// The optional that governs how observations are spaced. /// The value that defines the schedule's starting reference. /// The list of values the field should produce; when null, a list containing is stored. /// The labels associated with the field, or null when no labels are provided. /// public GroupedField( string? name, List? names, string? group, List? startTimeShift, int max, GroupedObservationEnum.Regularity? regularity, GroupedObservationEnum.Since since, List? result, List? labelList) { Name = name; Names = names ?? []; Group = group; StartTimeShift = startTimeShift ?? []; Max = max; Regularity = regularity; Since = since; Result = result ?? [GroupedObservationEnum.Result.First]; LabelList = labelList; } public string? Name { get; init; } public List Names { get; init; } = []; public string? Group { get; init; } public List StartTimeShift { get; init; } = []; public int Max { get; init; } public GroupedObservationEnum.Regularity? Regularity { get; init; } public GroupedObservationEnum.Since Since { get; init; } public List Result { get; init; } = []; public List? LabelList { get; init; } /// /// Retrieves the list of names stored in the current instance. /// /// A containing the names; returns the underlying field directly without copying or filtering. /// public List GetNames() { return Names; } /// /// Determines whether the specified object is equal to the current by comparing their Group property values. /// Returns true only when is a instance with a matching Group; otherwise returns false (including for null or non-matching types). /// /// The object to compare with the current instance. /// true if the specified object is a with the same Group; otherwise, false. /// public override bool Equals(object? obj) { return obj is GroupedField field && Group == field.Group; } /// /// Computes a hash code for the current instance by combining the values of its key properties: Name, Group, Max, Regularity, and Result. /// This override ensures consistent hash-based behavior for equality comparisons and use in hash-based collections. /// /// An integer hash code derived from the object's key properties. /// public override int GetHashCode() { return HashCode.Combine(Name, Group, Max, Regularity, Result); } }