readConfig<T> method

  1. @override
T readConfig<T>(
  1. Config<T> config,
  2. TreeNode scope
)
override

Implementation

@override
T readConfig<T>(Config<T> config, TreeNode scope) {
  final scopePath = scope.getConfigPath();
  return switch (config) {
    PathConfig<Enum?>(
      :final path,
      :final T defaultValue?,
      :final List<T> values?,
    ) =>
      configuration.readEnum<T?>(scopePath.join(ConfigPath(path)), values) ??
          defaultValue,
    PathConfig<Enum?>(:final path, :final List<T> values?) =>
      configuration.readEnum<T>(scopePath.join(ConfigPath(path)), values),
    PathConfig<T>(:final path, :final defaultValue?) =>
      configuration.read<T?>(scopePath.join(ConfigPath(path))) ??
          defaultValue,
    PathConfig<T>(:final path) => configuration.read<T>(
      scopePath.join(ConfigPath(path)),
    ),
    ValueConfig<T>(:final value) => value,
  };
}