setFrom method
Copies compatible fields from any other instance of CrystallisData.
Incompatible fields (missing or type-mismatched) are skipped.
Null values are skipped.
Implementation
@override
void setFrom(CrystallisData other) {
// skip this both this and other are of the same type
final bool isSameType = this.runtimeType == other.runtimeType;
for (final name in metadata.keys) {
if (!isSameType) {
final thisMeta = metadata[name]!;
final otherMeta = other.metadata[name];
/// TODO(kerberjg): dart-format-off is not working here...
// skip when...
if ( //
otherMeta == null // missing
||
otherMeta.type != thisMeta.type // type-mismatched fields
||
!thisMeta.mutable // this field is immutable
) {
continue;
}
}
final value = other.get(name);
// skip null values
if (value != null) {
set(name, value);
}
}
}