86 lines
3.2 KiB
C#
86 lines
3.2 KiB
C#
using adas_core.Domain.Enums;
|
|
|
|
namespace adas_core.Domain.Models.GroupedObservations;
|
|
|
|
/// <summary>
|
|
/// Represents a field that belongs to a logical grouping, encapsulating the concept of a field within a grouped structure.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// 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.
|
|
/// </remarks>
|
|
public class GroupedField
|
|
{
|
|
public GroupedField()
|
|
{
|
|
}
|
|
|
|
public GroupedField(
|
|
string? name,
|
|
List<string>? names,
|
|
string? group,
|
|
List<string>? startTimeShift,
|
|
int max,
|
|
GroupedObservationEnum.Regularity? regularity,
|
|
GroupedObservationEnum.Since since,
|
|
List<GroupedObservationEnum.Result>? result,
|
|
List<string>? 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<string> Names { get; init; } = [];
|
|
|
|
public string? Group { get; init; }
|
|
|
|
public List<string> StartTimeShift { get; init; } = [];
|
|
|
|
public int Max { get; init; }
|
|
|
|
public GroupedObservationEnum.Regularity? Regularity { get; init; }
|
|
|
|
public GroupedObservationEnum.Since Since { get; init; }
|
|
|
|
public List<GroupedObservationEnum.Result> Result { get; init; } = [];
|
|
|
|
public List<string>? LabelList { get; init; }
|
|
|
|
/// <summary>
|
|
/// Retrieves the list of names stored in the current instance.
|
|
/// </summary>
|
|
/// <returns>A <see cref="List{String}"/> containing the names; returns the underlying field directly without copying or filtering.</returns>
|
|
public List<string> GetNames()
|
|
{
|
|
return Names;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines whether the specified object is equal to the current <see cref="GroupedField"/> by comparing their <c>Group</c> property values.
|
|
/// Returns <c>true</c> only when <paramref name="obj"/> is a <see cref="GroupedField"/> instance with a matching <c>Group</c>; otherwise returns <c>false</c> (including for <c>null</c> or non-matching types).
|
|
/// </summary>
|
|
/// <param name="obj">The object to compare with the current instance.</param>
|
|
/// <returns><c>true</c> if the specified object is a <see cref="GroupedField"/> with the same <c>Group</c>; otherwise, <c>false</c>.</returns>
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return obj is GroupedField field && Group == field.Group;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
/// <returns>An integer hash code derived from the object's key properties.</returns>
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(Name, Group, Max, Regularity, Result);
|
|
}
|
|
} |