copyWith method

DependencyMetadata copyWith({
  1. Entity groupEntity = const DefaultEntity(),
  2. Entity preemptivetypeEntity = const DefaultEntity(),
  3. Option<Type> initialType = const None(),
  4. Option<int> index = const None(),
  5. Option<TOnUnregisterCallback<Object>> onUnregister = const None(),
})

Creates a new instance with updated fields, preserving the values of any fields not explicitly specified.

Implementation

DependencyMetadata copyWith({
  Entity groupEntity = const DefaultEntity(),
  Entity preemptivetypeEntity = const DefaultEntity(),
  Option<Type> initialType = const None(),
  Option<int> index = const None(),
  Option<TOnUnregisterCallback<Object>> onUnregister = const None(),
}) {
  return DependencyMetadata(
    groupEntity: groupEntity.isNotDefault() ? groupEntity : this.groupEntity,
    preemptivetypeEntity: preemptivetypeEntity.isNotDefault()
        ? preemptivetypeEntity
        : this.preemptivetypeEntity,
    index: switch (index) {
      Some() => index,
      None() => this.index,
    },
    onUnregister: switch (onUnregister) {
      Some() => onUnregister,
      None() => this.onUnregister,
    },
  ).._initialType = switch (initialType) {
      Some() => initialType,
      None() => _initialType,
    };
}