fromJson<LineAddressType extends Object, TransactionTagType extends Object, MetadataType extends Object> static method
- Map<
String, Object?> json, { - required StateValueDecoder<
LineAddressType> decodeLineAddress, - required StateValueDecoder<
TransactionTagType> decodeTransactionTag, - required StateValueDecoder<
MetadataType> decodeMetadata,
Decodes a miss-status image.
Implementation
static MissStatusTableImage<LineAddressType, TransactionTagType, MetadataType>
fromJson<LineAddressType extends Object,
TransactionTagType extends Object, MetadataType extends Object>(
Map<String, Object?> json, {
required StateValueDecoder<LineAddressType> decodeLineAddress,
required StateValueDecoder<TransactionTagType> decodeTransactionTag,
required StateValueDecoder<MetadataType> decodeMetadata,
}) {
_validateHeader(json, kind, version);
final capacity = _positiveInt(json, 'capacity');
final decoded = List<
MissStatusEntryImage<LineAddressType, TransactionTagType,
MetadataType>?>.filled(capacity, null);
for (final encoded in _entryList(json)) {
final entry = _entryMap(encoded);
final index = _entryIndex(entry, capacity);
final mergeCount = entry['mergeCount'];
final issued = entry['issued'];
final completed = entry['completed'];
if (decoded[index] != null) {
throw FormatException('Duplicate state entry index $index.');
}
if (mergeCount is! int || mergeCount <= 0) {
throw const FormatException('mergeCount must be a positive integer.');
}
if (issued is! bool || completed is! bool) {
throw const FormatException('Lifecycle fields must be booleans.');
}
decoded[index] = MissStatusEntryImage(
lineAddress: decodeLineAddress(entry['lineAddress']),
transactionTag: decodeTransactionTag(entry['transactionTag']),
metadata: decodeMetadata(entry['metadata']),
mergeCount: mergeCount,
issued: issued,
completed: completed,
);
}
return MissStatusTableImage(decoded);
}