copyWith method

EntityResolutionRules copyWith({
  1. bool? allowEntityFetch,
  2. bool? allowReadFile,
  3. List<Type>? lazyEntityTypes,
  4. List<Type>? eagerEntityTypes,
  5. bool? allLazy,
  6. bool? allEager,
  7. bool? mergeTolerant,
  8. List<Type>? conflictingEntityTypes,
})

Copies this instance, allowing fields overwrite.

  • conflictingEntityTypes informs the Types to remove from lazyEntityTypes and eagerEntityTypes.

Implementation

EntityResolutionRules copyWith({
  bool? allowEntityFetch,
  bool? allowReadFile,
  List<Type>? lazyEntityTypes,
  List<Type>? eagerEntityTypes,
  bool? allLazy,
  bool? allEager,
  bool? mergeTolerant,
  List<Type>? conflictingEntityTypes,
}) {
  lazyEntityTypes ??= this.lazyEntityTypes;
  eagerEntityTypes ??= this.eagerEntityTypes;

  if (conflictingEntityTypes != null && conflictingEntityTypes.isNotEmpty) {
    lazyEntityTypes = lazyEntityTypes.without(conflictingEntityTypes);
    eagerEntityTypes = eagerEntityTypes.without(conflictingEntityTypes);
  }

  lazyEntityTypes = lazyEntityTypes.nullIfEmpty();
  eagerEntityTypes = eagerEntityTypes.nullIfEmpty();

  var resolutionRules = EntityResolutionRules(
    allowEntityFetch: allowEntityFetch ?? _allowEntityFetch,
    allowReadFile: allowReadFile ?? this.allowReadFile,
    lazyEntityTypes: lazyEntityTypes,
    eagerEntityTypes: eagerEntityTypes,
    allLazy: allLazy ?? this.allLazy,
    allEager: allEager ?? this.allEager,
    mergeTolerant: mergeTolerant ?? this.mergeTolerant,
  );

  return resolutionRules.isInnocuous ? innocuous : resolutionRules;
}