copyWith method

EntertainmentConfiguration copyWith({
  1. ResourceType? type,
  2. String? id,
  3. String? idV1,
  4. EntertainmentConfigurationMetadata? metadata,
  5. String? name,
  6. String? configurationType,
  7. String? status,
  8. Relative? activeStreamer,
  9. EntertainmentConfigurationStreamProxy? streamProxy,
  10. List<EntertainmentConfigurationChannel>? channels,
  11. List<EntertainmentConfigurationLocation>? locations,
  12. List<Relative>? lightServices,
  13. String? action = "",
  14. bool copyOriginalValues = true,
})

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

Since action is nullable, it is defaulted to an empty string in this method. If left as an empty string, its current value in this EntertainmentConfiguration object will be used. This way, if it is null, the program will know that it is intentionally being set to null.

copyOriginalValues is true if you want to maintain the original object's initial values. This is useful if you plan on using this object in a PUT request.

Implementation

EntertainmentConfiguration copyWith({
  ResourceType? type,
  String? id,
  String? idV1,
  EntertainmentConfigurationMetadata? metadata,
  String? name,
  String? configurationType,
  String? status,
  Relative? activeStreamer,
  EntertainmentConfigurationStreamProxy? streamProxy,
  List<EntertainmentConfigurationChannel>? channels,
  List<EntertainmentConfigurationLocation>? locations,
  List<Relative>? lightServices,
  String? action = "",
  bool copyOriginalValues = true,
}) {
  EntertainmentConfiguration toReturn = EntertainmentConfiguration(
    type: copyOriginalValues ? originalType : (type ?? this.type),
    id: id ?? this.id,
    idV1: idV1 ?? this.idV1,
    metadata: copyOriginalValues
        ? _originalMetadata.copyWith(copyOriginalValues: copyOriginalValues)
        : (metadata ??
            this.metadata.copyWith(copyOriginalValues: copyOriginalValues)),
    name: name ?? this.name,
    configurationType: copyOriginalValues
        ? _originalConfigurationType
        : (configurationType ?? this.configurationType),
    status: status ?? this.status,
    activeStreamer: activeStreamer ?? this.activeStreamer,
    streamProxy: copyOriginalValues
        ? _originalStreamProxy
        : (streamProxy ?? this.streamProxy),
    channels: channels ??
        this.channels.map((channel) => channel.copyWith()).toList(),
    locations: copyOriginalValues
        ? _originalLocations
        : (locations ??
            this.locations.map((location) => location.copyWith()).toList()),
    lightServices: lightServices ??
        this
            .lightServices
            .map((lightService) => lightService.copyWith())
            .toList(),
    action: copyOriginalValues
        ? _originalAction
        : (action == null || action.isNotEmpty ? action : this.action),
  );

  if (copyOriginalValues) {
    toReturn.type = type ?? this.type;
    toReturn.metadata = metadata ??
        this.metadata.copyWith(copyOriginalValues: copyOriginalValues);
    toReturn.configurationType = configurationType ?? this.configurationType;
    toReturn.streamProxy = streamProxy ?? this.streamProxy;
    toReturn.locations = locations ??
        this.locations.map((location) => location.copyWith()).toList();
    toReturn.action =
        action == null || action.isNotEmpty ? action : this.action;
  }

  return toReturn;
}