LotSizingDataModel.Core 2.0.1
Core domain model, shared abstractions and XML-serializable entities.
Loading...
Searching...
No Matches
TransportCharacteristic.cs
Go to the documentation of this file.
1using System;
2using System.Xml.Serialization;
4
6
7/// <summary>
8/// Represents the transport characteristics of an item
9/// for a specific transport resource.
10///
11/// Corresponds to the UML association class
12/// "Caracteristique Transport" between Article
13/// and Moyen de transport.
14///
15/// Period-dependent capacities and costs will be added
16/// through another partial declaration of this class.
17/// </summary>
18[Serializable]
19[XmlType(TypeName = "transportCharacteristic")]
20public sealed partial class TransportCharacteristic : ModelObject
21{
22 private int _itemId;
23 private int _transportResourceId;
24
25 /// <summary>
26 /// Initializes an empty transport characteristic.
27 ///
28 /// This public parameterless constructor is required
29 /// by <see cref="XmlSerializer"/>.
30 /// </summary>
32 {
33 }
34
35 /// <summary>
36 /// Initializes a transport characteristic.
37 /// </summary>
38 /// <param name="itemId">
39 /// Identifier of the transported item.
40 /// </param>
41 /// <param name="transportResourceId">
42 /// Identifier of the transport resource.
43 /// </param>
45 int itemId,
46 int transportResourceId)
47 {
48 // Initialize transport characteristic properties (validation occurs in setters)
49 ItemId = itemId;
50 TransportResourceId = transportResourceId;
51 }
52
53 /// <summary>
54 /// Gets or sets the identifier of the item transported
55 /// by the referenced transport resource.
56 /// </summary>
57 [XmlAttribute("itemId")]
58 public int ItemId
59 {
60 get => _itemId;
61 set
62 {
63 // Validate that the item identifier is non-negative
64 if (value < 0)
65 {
66 throw new ArgumentOutOfRangeException(
67 nameof(value),
68 value,
69 "The item identifier cannot be negative.");
70 }
71
72 // Update the backing field and notify property change if value differs
73 SetProperty(ref _itemId, value);
74 }
75 }
76
77 /// <summary>
78 /// Gets or sets the identifier of the transport resource
79 /// associated with the item.
80 /// </summary>
81 [XmlAttribute("transportResourceId")]
83 {
84 get => _transportResourceId;
85 set
86 {
87 // Validate that the transport resource identifier is non-negative
88 if (value < 0)
89 {
90 throw new ArgumentOutOfRangeException(
91 nameof(value),
92 value,
93 "The transport-resource identifier cannot be negative.");
94 }
95
96 // Update the backing field and notify property change if value differs
97 SetProperty(
98 ref _transportResourceId,
99 value);
100 }
101 }
102
103 /// <summary>
104 /// Determines whether this object represents the same
105 /// item/transport-resource association as another object.
106 /// </summary>
109 {
110 // Compare both item ID and transport resource ID for equality
111 return other is not null
112 && ItemId == other.ItemId
115 }
116
117 /// <summary>
118 /// Determines whether this transport characteristic
119 /// concerns the specified item.
120 /// </summary>
121 public bool ConcernsItem(int itemId)
122 {
123 return ItemId == itemId;
124 }
125
126 /// <summary>
127 /// Determines whether this transport characteristic
128 /// concerns the specified transport resource.
129 /// </summary>
131 int transportResourceId)
132 {
133 // Check if the transport resource ID matches
134 return TransportResourceId ==
135 transportResourceId;
136 }
137}
Base class for model objects that notify listeners when one of their properties changes.
TransportCharacteristic(int itemId, int transportResourceId)
Initializes a transport characteristic.
bool ConcernsTransportResource(int transportResourceId)
Determines whether this transport characteristic concerns the specified transport resource.
bool ConcernsItem(int itemId)
Determines whether this transport characteristic concerns the specified item.
bool RefersToSameAssociation(TransportCharacteristic? other)
Determines whether this object represents the same item/transport-resource association as another obj...
int ItemId
Gets or sets the identifier of the item transported by the referenced transport resource.
TransportCharacteristic()
Initializes an empty transport characteristic.
int TransportResourceId
Gets or sets the identifier of the transport resource associated with the item.