copyWith method
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 object in this
method. If left as an empty object, its current value in this
ZigbeeDeviceDiscovery 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
ZigbeeDeviceDiscovery copyWith({
ResourceType? type,
String? id,
String? idV1,
Relative? owner,
String? status,
Object? action = sentinelValue,
bool copyOriginalValues = true,
}) {
if (!identical(action, sentinelValue)) {
assert(action is ZigbeeDeviceDiscoveryAction?,
"`action` must be a `ZigbeeDeviceDiscoveryAction?` object");
}
ZigbeeDeviceDiscovery toReturn = ZigbeeDeviceDiscovery(
type: copyOriginalValues ? originalType : (type ?? this.type),
id: id ?? this.id,
idV1: idV1 ?? this.idV1,
owner:
owner ?? this.owner.copyWith(copyOriginalValues: copyOriginalValues),
status: status ?? this.status,
action: copyOriginalValues
? _originalAction?.copyWith(copyOriginalValues: copyOriginalValues)
: (identical(action, sentinelValue)
? this.action?.copyWith(copyOriginalValues: copyOriginalValues)
: action as ZigbeeDeviceDiscoveryAction?),
);
if (copyOriginalValues) {
toReturn.type = type ?? this.type;
toReturn.action = identical(action, sentinelValue)
? this.action?.copyWith(copyOriginalValues: copyOriginalValues)
: action as ZigbeeDeviceDiscoveryAction?;
}
return toReturn;
}