copyWith method
DeviceMetadata
copyWith({
- String? name,
- DeviceArchetype? archetype,
- bool copyOriginalValues = true,
Returns a copy of this object with its field values replaced by the ones provided to this method.
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
DeviceMetadata copyWith({
String? name,
DeviceArchetype? archetype,
bool copyOriginalValues = true,
}) {
DeviceMetadata toReturn = DeviceMetadata(
name: copyOriginalValues ? _originalName : (name ?? this.name),
archetype: copyOriginalValues
? _originalArchetype
: (archetype ?? this.archetype),
);
if (copyOriginalValues) {
toReturn.name = name ?? this.name;
toReturn.archetype = archetype ?? this.archetype;
}
return toReturn;
}