PatchbaySnapshotRequest constructor

PatchbaySnapshotRequest({
  1. required String path,
  2. PatchbaySnapshotCondition? until,
  3. Object? value,
  4. Duration? timeout,
})

Implementation

PatchbaySnapshotRequest({
  required this.path,
  this.until,
  this.value,
  this.timeout,
}) {
  if (!_path.hasMatch(path)) {
    throw FormatException(
      'path must be dot-separated segments matching ${_path.pattern}',
    );
  }
  if (until == null) {
    if (value != null) {
      throw const FormatException('value requires until: equals');
    }
    if (timeout != null) {
      throw const FormatException('timeoutMs requires until');
    }
    return;
  }
  if (timeout == null) {
    throw const FormatException('a wait requires timeoutMs');
  }
  if (timeout! <= Duration.zero || timeout! > patchbaySnapshotWaitCeiling) {
    throw FormatException(
      'timeoutMs must be greater than zero and at most '
      '${patchbaySnapshotWaitCeiling.inMilliseconds}',
    );
  }
  if ((until == PatchbaySnapshotCondition.equals) != (value != null)) {
    throw const FormatException(
      'until: equals requires value, and value is accepted only with it',
    );
  }
}