Skip to content

Commit

Permalink
fix order of member declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
smdn committed Apr 2, 2024
1 parent f3ed941 commit 453a2b2
Show file tree
Hide file tree
Showing 15 changed files with 515 additions and 506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,6 @@ namespace Smdn.Net.EchonetLite.Appendix;
/// クラスグループ
/// </summary>
public sealed class EchonetClassGroupSpecification {
/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
/// <param name="code"><see cref="Code"/>に設定する値。</param>
/// <param name="name"><see cref="Name"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <param name="propertyName"><see cref="PropertyName"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <param name="superClassName"><see cref="SuperClassName"/>に設定する値。 スーパークラスがない場合は<see langword="null"/>。 空の文字列は<see langword="null"/>として設定されます。</param>
/// <param name="classes"><see cref="Classes"/>に設定する値。 <see langword="null"/>が指定された場合は、空の<see cref="IReadOnlyList{EchonetClassSpecification}"/>を設定します。</param>
/// <exception cref="ArgumentNullException"><see langword="null"/>非許容のプロパティに<see langword="null"/>を設定しようとしました。</exception>
/// <exception cref="ArgumentException">プロパティに空の文字列を設定しようとしました。</exception>
[JsonConstructor]
public EchonetClassGroupSpecification(
byte code,
string? name,
string? propertyName,
string? superClassName,
IReadOnlyList<EchonetClassSpecification>? classes
)
{
Code = code;
Name = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(name, nameof(name));
PropertyName = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(propertyName, nameof(propertyName));
SuperClassName = string.IsNullOrEmpty(superClassName) ? null : superClassName; // can be null
Classes = classes ?? Array.Empty<EchonetClassSpecification>();
}

/// <summary>
/// クラスグループコード
/// </summary>
Expand Down Expand Up @@ -67,4 +41,30 @@ public sealed class EchonetClassGroupSpecification {
/// </summary>
[JsonPropertyName("ClassList")]
public IReadOnlyList<EchonetClassSpecification> Classes { get; }

/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
/// <param name="code"><see cref="Code"/>に設定する値。</param>
/// <param name="name"><see cref="Name"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <param name="propertyName"><see cref="PropertyName"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <param name="superClassName"><see cref="SuperClassName"/>に設定する値。 スーパークラスがない場合は<see langword="null"/>。 空の文字列は<see langword="null"/>として設定されます。</param>
/// <param name="classes"><see cref="Classes"/>に設定する値。 <see langword="null"/>が指定された場合は、空の<see cref="IReadOnlyList{EchonetClassSpecification}"/>を設定します。</param>
/// <exception cref="ArgumentNullException"><see langword="null"/>非許容のプロパティに<see langword="null"/>を設定しようとしました。</exception>
/// <exception cref="ArgumentException">プロパティに空の文字列を設定しようとしました。</exception>
[JsonConstructor]
public EchonetClassGroupSpecification(
byte code,
string? name,
string? propertyName,
string? superClassName,
IReadOnlyList<EchonetClassSpecification>? classes
)
{
Code = code;
Name = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(name, nameof(name));
PropertyName = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(propertyName, nameof(propertyName));
SuperClassName = string.IsNullOrEmpty(superClassName) ? null : superClassName; // can be null
Classes = classes ?? Array.Empty<EchonetClassSpecification>();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,6 @@ namespace Smdn.Net.EchonetLite.Appendix;
/// クラス
/// </summary>
public sealed class EchonetClassSpecification {
/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
/// <param name="isDefined"><see cref="IsDefined"/>に設定する値。</param>
/// <param name="code"><see cref="Code"/>に設定する値。</param>
/// <param name="name"><see cref="Name"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <param name="propertyName"><see cref="PropertyName"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <exception cref="ArgumentNullException"><see langword="null"/>非許容のプロパティに<see langword="null"/>を設定しようとしました。</exception>
/// <exception cref="ArgumentException">プロパティに空の文字列を設定しようとしました。</exception>
[JsonConstructor]
public EchonetClassSpecification(
bool isDefined,
byte code,
string? name,
string? propertyName
)
{
IsDefined = isDefined;
Code = code;
Name = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(name, nameof(name));
PropertyName = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(propertyName, nameof(propertyName));
}

/// <summary>
/// 詳細仕様有無
/// </summary>
Expand All @@ -57,4 +34,27 @@ public sealed class EchonetClassSpecification {
/// </summary>
[JsonPropertyName("ClassName")]
public string PropertyName { get; }

/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
/// <param name="isDefined"><see cref="IsDefined"/>に設定する値。</param>
/// <param name="code"><see cref="Code"/>に設定する値。</param>
/// <param name="name"><see cref="Name"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <param name="propertyName"><see cref="PropertyName"/>に設定する非<see langword="null"/>・長さ非ゼロの値。</param>
/// <exception cref="ArgumentNullException"><see langword="null"/>非許容のプロパティに<see langword="null"/>を設定しようとしました。</exception>
/// <exception cref="ArgumentException">プロパティに空の文字列を設定しようとしました。</exception>
[JsonConstructor]
public EchonetClassSpecification(
bool isDefined,
byte code,
string? name,
string? propertyName
)
{
IsDefined = isDefined;
Code = code;
Name = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(name, nameof(name));
PropertyName = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(propertyName, nameof(propertyName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,41 @@ internal static EchonetObjectSpecification CreateUnknown(byte classGroupCode, by
)
);

/*
* instance members
*/
/// <summary>
/// クラスグループ情報
/// クラスグループコード
/// </summary>
public EchonetClassGroupSpecification ClassGroup { get; }

/// <summary>
/// クラス情報
/// クラスコード
/// </summary>
public EchonetClassSpecification Class { get; }

/// <summary>
/// 仕様上定義済みのプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> AllProperties { get; }

/// <summary>
/// 仕様上定義済みのGETプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> GetProperties { get; }

/// <summary>
/// 仕様上定義済みのSETプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> SetProperties { get; }

/// <summary>
/// 仕様上定義済みのANNOプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> AnnoProperties { get; }

internal EchonetObjectSpecification(
byte classGroupCode,
byte classCode
Expand Down Expand Up @@ -101,36 +136,4 @@ IReadOnlyList<EchonetPropertySpecification> Properties
return keyedSpecs;
}
}

/// <summary>
/// クラスグループ情報
/// クラスグループコード
/// </summary>
public EchonetClassGroupSpecification ClassGroup { get; }

/// <summary>
/// クラス情報
/// クラスコード
/// </summary>
public EchonetClassSpecification Class { get; }

/// <summary>
/// 仕様上定義済みのプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> AllProperties { get; }

/// <summary>
/// 仕様上定義済みのGETプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> GetProperties { get; }

/// <summary>
/// 仕様上定義済みのSETプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> SetProperties { get; }

/// <summary>
/// 仕様上定義済みのANNOプロパティの一覧
/// </summary>
public IReadOnlyDictionary<byte, EchonetPropertySpecification> AnnoProperties { get; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,75 +48,9 @@ internal static EchonetPropertySpecification CreateUnknown(byte code)
unit: null
);

/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
/// <param name="name"><see cref="Name"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="code"><see cref="Code"/>に設定する値。</param>
/// <param name="detail"><see cref="Detail"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="valueRange"><see cref="ValueRange"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <param name="dataType"><see cref="DataType"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="logicalDataType"><see cref="LogicalDataType"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="minSize"><see cref="MinSize"/>に設定する値。</param>
/// <param name="maxSize"><see cref="MaxSize"/>に設定する値。</param>
/// <param name="canGet"><see cref="CanGet"/>に設定する値。</param>
/// <param name="isGetMandatory"><see cref="IsGetMandatory"/>に設定する値。</param>
/// <param name="canSet"><see cref="CanSet"/>に設定する値。</param>
/// <param name="isSetMandatory"><see cref="IsSetMandatory"/>に設定する値。</param>
/// <param name="canAnnounceStatusChange"><see cref="CanAnnounceStatusChange"/>に設定する値。</param>
/// <param name="isStatusChangeAnnouncementMandatory"><see cref="IsStatusChangeAnnouncementMandatory"/>に設定する値。</param>
/// <param name="optionRequired"><see cref="OptionRequired"/>に設定する値。 <see langword="null"/>が指定された場合は、空の<see cref="IReadOnlyList{ApplicationServiceName}"/>を設定します。</param>
/// <param name="description"><see cref="Description"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <param name="unit"><see cref="Unit"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <exception cref="ArgumentNullException"><see langword="null"/>非許容のプロパティに<see langword="null"/>を設定しようとしました。</exception>
/// <exception cref="ArgumentException">プロパティに空の文字列を設定しようとしました。</exception>
[JsonConstructor]
public EchonetPropertySpecification(
string? name,
byte code,
string? detail,
string? valueRange,
string? dataType,
string? logicalDataType,
int? minSize,
int? maxSize,
bool canGet,
bool isGetMandatory,
bool canSet,
bool isSetMandatory,
bool canAnnounceStatusChange,
bool isStatusChangeAnnouncementMandatory,
IReadOnlyList<ApplicationServiceName>? optionRequired,
string? description,
string? unit
)
{
Name = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(name, nameof(name));
Code = code;
Detail = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(detail, nameof(detail));
ValueRange = string.IsNullOrEmpty(valueRange) ? null : valueRange;
DataType = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(dataType, nameof(dataType));
LogicalDataType = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(logicalDataType, nameof(logicalDataType));
MinSize = minSize;
MaxSize = maxSize;
CanGet = canGet;
IsGetMandatory = isGetMandatory;
CanSet = canSet;
IsSetMandatory = isSetMandatory;
CanAnnounceStatusChange = canAnnounceStatusChange;
IsStatusChangeAnnouncementMandatory = isStatusChangeAnnouncementMandatory;
OptionRequired = optionRequired ?? Array.Empty<ApplicationServiceName>();
Description = string.IsNullOrEmpty(description) ? null : description;
Unit = string.IsNullOrEmpty(unit) ? null : unit;

if (string.IsNullOrEmpty(unit) || "".Equals(Unit, StringComparison.Ordinal)) {
Unit = null;
HasUnit = false;
}
else {
HasUnit = true;
}
}
/*
* instance members
*/

/// <summary>
/// プロパティ名称
Expand Down Expand Up @@ -249,4 +183,74 @@ internal static EchonetPropertySpecification CreateUnknown(byte code)
[MemberNotNullWhen(true, nameof(Unit))]
#endif
public bool HasUnit { get; }

/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
/// <param name="name"><see cref="Name"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="code"><see cref="Code"/>に設定する値。</param>
/// <param name="detail"><see cref="Detail"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="valueRange"><see cref="ValueRange"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <param name="dataType"><see cref="DataType"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="logicalDataType"><see cref="LogicalDataType"/>に設定する非<see langword="null"/>の値。</param>
/// <param name="minSize"><see cref="MinSize"/>に設定する値。</param>
/// <param name="maxSize"><see cref="MaxSize"/>に設定する値。</param>
/// <param name="canGet"><see cref="CanGet"/>に設定する値。</param>
/// <param name="isGetMandatory"><see cref="IsGetMandatory"/>に設定する値。</param>
/// <param name="canSet"><see cref="CanSet"/>に設定する値。</param>
/// <param name="isSetMandatory"><see cref="IsSetMandatory"/>に設定する値。</param>
/// <param name="canAnnounceStatusChange"><see cref="CanAnnounceStatusChange"/>に設定する値。</param>
/// <param name="isStatusChangeAnnouncementMandatory"><see cref="IsStatusChangeAnnouncementMandatory"/>に設定する値。</param>
/// <param name="optionRequired"><see cref="OptionRequired"/>に設定する値。 <see langword="null"/>が指定された場合は、空の<see cref="IReadOnlyList{ApplicationServiceName}"/>を設定します。</param>
/// <param name="description"><see cref="Description"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <param name="unit"><see cref="Unit"/>に設定する値。 <see langword="null"/>または空の場合は、<see langword="null"/>として設定されます。</param>
/// <exception cref="ArgumentNullException"><see langword="null"/>非許容のプロパティに<see langword="null"/>を設定しようとしました。</exception>
/// <exception cref="ArgumentException">プロパティに空の文字列を設定しようとしました。</exception>
[JsonConstructor]
public EchonetPropertySpecification(
string? name,
byte code,
string? detail,
string? valueRange,
string? dataType,
string? logicalDataType,
int? minSize,
int? maxSize,
bool canGet,
bool isGetMandatory,
bool canSet,
bool isSetMandatory,
bool canAnnounceStatusChange,
bool isStatusChangeAnnouncementMandatory,
IReadOnlyList<ApplicationServiceName>? optionRequired,
string? description,
string? unit
)
{
Name = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(name, nameof(name));
Code = code;
Detail = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(detail, nameof(detail));
ValueRange = string.IsNullOrEmpty(valueRange) ? null : valueRange;
DataType = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(dataType, nameof(dataType));
LogicalDataType = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(logicalDataType, nameof(logicalDataType));
MinSize = minSize;
MaxSize = maxSize;
CanGet = canGet;
IsGetMandatory = isGetMandatory;
CanSet = canSet;
IsSetMandatory = isSetMandatory;
CanAnnounceStatusChange = canAnnounceStatusChange;
IsStatusChangeAnnouncementMandatory = isStatusChangeAnnouncementMandatory;
OptionRequired = optionRequired ?? Array.Empty<ApplicationServiceName>();
Description = string.IsNullOrEmpty(description) ? null : description;
Unit = string.IsNullOrEmpty(unit) ? null : unit;

if (string.IsNullOrEmpty(unit) || "".Equals(Unit, StringComparison.Ordinal)) {
Unit = null;
HasUnit = false;
}
else {
HasUnit = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@
namespace Smdn.Net.EchonetLite.Appendix;

internal sealed class PropertyMaster {
/// <summary>
/// ECHONET Lite SPECIFICATIONのバージョン
/// </summary>
public string Version { get; }

/// <summary>
/// APPENDIX ECHONET 機器オブジェクト詳細規定のリリース番号
/// </summary>
public string AppendixRelease { get; }

/// <summary>
/// プロパティのリスト
/// </summary>
public IReadOnlyList<EchonetPropertySpecification> Properties { get; }

/// <summary>
/// JSONデシリアライズ用のコンストラクタ
/// </summary>
Expand All @@ -29,19 +44,4 @@ internal sealed class PropertyMaster {
AppendixRelease = JsonValidationUtils.ThrowIfValueIsNullOrEmpty(appendixRelease, nameof(appendixRelease));
Properties = properties ?? throw new ArgumentNullException(nameof(properties));
}

/// <summary>
/// ECHONET Lite SPECIFICATIONのバージョン
/// </summary>
public string Version { get; }

/// <summary>
/// APPENDIX ECHONET 機器オブジェクト詳細規定のリリース番号
/// </summary>
public string AppendixRelease { get; }

/// <summary>
/// プロパティのリスト
/// </summary>
public IReadOnlyList<EchonetPropertySpecification> Properties { get; }
}
Loading

0 comments on commit 453a2b2

Please sign in to comment.