| | 1 | | using System.Diagnostics.CodeAnalysis; |
| | 2 | | using System.Text.Json.Serialization; |
| | 3 | | using Spdx3.Model.Core.Enums; |
| | 4 | | using Spdx3.Model.Lite; |
| | 5 | | using Spdx3.Serialization; |
| | 6 | | using Spdx3.Utility; |
| | 7 | |
|
| | 8 | | namespace Spdx3.Model.Core.Classes; |
| | 9 | |
|
| | 10 | | /// <summary> |
| | 11 | | /// A mathematically calculated representation of a grouping of data. |
| | 12 | | /// See https://spdx.github.io/spdx-spec/v3.0.1/model/Core/Classes/Hash/ |
| | 13 | | /// </summary> |
| | 14 | | public class Hash : IntegrityMethod, ILiteDomainCompliantElement |
| | 15 | | { |
| | 16 | | [JsonPropertyName("algorithm")] |
| | 17 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 33 | 18 | | public required HashAlgorithm Algorithm { get; set; } |
| | 19 | |
|
| | 20 | | [JsonPropertyName("hashValue")] |
| | 21 | | [JsonConverter(typeof(SpdxModelConverterFactory))] |
| 33 | 22 | | public required string HashValue { get; set; } |
| | 23 | |
|
| | 24 | | // protected internal no-parm constructor required for deserialization |
| | 25 | | // ReSharper disable once UnusedMember.Global |
| 1 | 26 | | protected internal Hash() |
| | 27 | | { |
| 1 | 28 | | } |
| | 29 | |
|
| | 30 | | [SetsRequiredMembers] |
| 22 | 31 | | public Hash(Catalog catalog, HashAlgorithm algorithm, string hashValue) : base(catalog) |
| | 32 | | { |
| 22 | 33 | | Algorithm = algorithm; |
| 22 | 34 | | HashValue = hashValue; |
| 22 | 35 | | } |
| | 36 | |
|
| | 37 | | public override void Validate() |
| | 38 | | { |
| 4 | 39 | | base.Validate(); |
| 3 | 40 | | ValidateRequiredProperty(nameof(Algorithm)); |
| 3 | 41 | | ValidateRequiredProperty(nameof(HashValue)); |
| 1 | 42 | | } |
| | 43 | |
|
| | 44 | | public void Accept(ILiteDomainComplianceVisitor visitor) |
| | 45 | | { |
| 3 | 46 | | visitor.Visit(this); |
| 3 | 47 | | } |
| | 48 | | } |