copyWith method

LightSignalingStatus copyWith({
  1. String? signal,
  2. List<String>? signalValues,
  3. DateTime? estimatedEnd,
})

Returns a copy of this object with its field values replaced by the ones provided to this method.

Throws InvalidValueException if the LightSignalingStatus copy has a signal that is not in its signalValues array.

Implementation

LightSignalingStatus copyWith({
  String? signal,
  List<String>? signalValues,
  DateTime? estimatedEnd,
}) {
  // Make sure [signal] is valid.
  if (signalValues != null &&
      signal == null &&
      !Validators.isValidValue(this.signal, signalValues)) {
    throw InvalidValueException.withValue(this.signal, signalValues);
  }

  return LightSignalingStatus(
    signal: signal ?? this.signal,
    signalValues: signalValues ?? List<String>.from(this.signalValues),
    estimatedEnd: estimatedEnd ?? this.estimatedEnd.copyWith(),
  );
}