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
{
public GroupedField()
{
}
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);
}
}