1+ // Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file 
2+ // for details. All rights reserved. Use of this source code is governed by a 
3+ // BSD-style license that can be found in the LICENSE file. 
4+ 
15import  'package:logging/logging.dart' ;
26import  'package:yaml/yaml.dart' ;
37
@@ -28,7 +32,7 @@ abstract class ConfigSpec<TE extends Object?, RE extends Object?> {
2832String ?  schemaDescription;
2933
3034  /// Custom validation hook, called post validation if successful. 
31- bool  Function (ConfigValue  node)?  customValidation;
35+ bool  Function (ConfigValue < Object ?>  node)?  customValidation;
3236
3337  /// Used to transform the payload to another type before passing to parent 
3438  /// nodes and [result] . 
@@ -44,9 +48,9 @@ abstract class ConfigSpec<TE extends Object?, RE extends Object?> {
4448    required  this .result,
4549  });
4650
47-   bool  _validateNode (ConfigValue  o, {bool  log =  true });
51+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true });
4852
49-   ConfigValue <RE > _extractNode (ConfigValue  o);
53+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o);
5054
5155  /// ConfigSpec objects should call [_getJsonRefOrSchemaNode]  instead to get 
5256  /// the child json schema. 
@@ -82,7 +86,7 @@ abstract class ConfigSpec<TE extends Object?, RE extends Object?> {
8286  /// all underlying ConfigSpecs if valid. 
8387  /// Should ideally only be called if [validate]  returns True. Throws 
8488  /// [ConfigSpecExtractionError]  if any validation fails. 
85- ConfigValue  extract (dynamic  value) {
89+ ConfigValue < Object ?>  extract (dynamic  value) {
8690    return  _extractNode (ConfigValue (path:  [], value:  value));
8791  }
8892}
@@ -159,7 +163,7 @@ class ConfigValue<TE> {
159163}
160164
161165class  ConfigSpecExtractionError  extends  Error  {
162-   final  ConfigValue ?  item;
166+   final  ConfigValue < Object ?> ?  item;
163167  final  String  message;
164168  ConfigSpecExtractionError (this .item, [this .message =  'Invalid ConfigSpec' ]);
165169
@@ -216,8 +220,8 @@ class HeterogeneousMapConfigSpec<CE extends Object?, RE extends Object?>
216220        allKeys =  {for  (final  kv in  entries) kv.key};
217221
218222  @override 
219-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
220-     if  (! o.checkType <Map >(log:  log)) {
223+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
224+     if  (! o.checkType <Map < dynamic ,  dynamic > >(log:  log)) {
221225      return  false ;
222226    }
223227
@@ -266,7 +270,7 @@ class HeterogeneousMapConfigSpec<CE extends Object?, RE extends Object?>
266270    return  result;
267271  }
268272
269-   dynamic  _getAllDefaults (ConfigValue  o) {
273+   dynamic  _getAllDefaults (ConfigValue < Object ?>  o) {
270274    final  result =  < dynamic , CE > {};
271275    for  (final  entry in  entries) {
272276      final  path =  [...o.path, entry.key];
@@ -298,8 +302,8 @@ class HeterogeneousMapConfigSpec<CE extends Object?, RE extends Object?>
298302  }
299303
300304  @override 
301-   ConfigValue <RE > _extractNode (ConfigValue  o) {
302-     if  (! o.checkType <Map >(log:  false )) {
305+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
306+     if  (! o.checkType <Map < dynamic ,  dynamic > >(log:  false )) {
303307      throw  ConfigSpecExtractionError (o);
304308    }
305309
@@ -405,8 +409,8 @@ class MapConfigSpec<CE extends Object?, RE extends Object?>
405409  });
406410
407411  @override 
408-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
409-     if  (! o.checkType <Map >(log:  log)) {
412+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
413+     if  (! o.checkType <Map < dynamic ,  dynamic > >(log:  log)) {
410414      return  false ;
411415    }
412416
@@ -457,8 +461,8 @@ class MapConfigSpec<CE extends Object?, RE extends Object?>
457461  }
458462
459463  @override 
460-   ConfigValue <RE > _extractNode (ConfigValue  o) {
461-     if  (! o.checkType <Map >(log:  false )) {
464+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
465+     if  (! o.checkType <Map < dynamic ,  dynamic > >(log:  false )) {
462466      throw  ConfigSpecExtractionError (o);
463467    }
464468
@@ -522,7 +526,7 @@ class ListConfigSpec<CE extends Object?, RE extends Object?>
522526  });
523527
524528  @override 
525-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
529+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
526530    if  (! o.checkType <YamlList >(log:  log)) {
527531      return  false ;
528532    }
@@ -544,7 +548,7 @@ class ListConfigSpec<CE extends Object?, RE extends Object?>
544548  }
545549
546550  @override 
547-   ConfigValue <RE > _extractNode (ConfigValue  o) {
551+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
548552    if  (! o.checkType <YamlList >(log:  false )) {
549553      throw  ConfigSpecExtractionError (o);
550554    }
@@ -591,7 +595,7 @@ class StringConfigSpec<RE extends Object?> extends ConfigSpec<String, RE> {
591595  }) :  _regexp =  pattern ==  null  ?  null  :  RegExp (pattern, dotAll:  true );
592596
593597  @override 
594-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
598+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
595599    if  (! o.checkType <String >(log:  log)) {
596600      return  false ;
597601    }
@@ -610,7 +614,7 @@ class StringConfigSpec<RE extends Object?> extends ConfigSpec<String, RE> {
610614  }
611615
612616  @override 
613-   ConfigValue <RE > _extractNode (ConfigValue  o) {
617+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
614618    if  (! o.checkType <String >(log:  false )) {
615619      throw  ConfigSpecExtractionError (o);
616620    }
@@ -642,7 +646,7 @@ class IntConfigSpec<RE extends Object?> extends ConfigSpec<int, RE> {
642646  });
643647
644648  @override 
645-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
649+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
646650    if  (! o.checkType <int >(log:  log)) {
647651      return  false ;
648652    }
@@ -653,7 +657,7 @@ class IntConfigSpec<RE extends Object?> extends ConfigSpec<int, RE> {
653657  }
654658
655659  @override 
656-   ConfigValue <RE > _extractNode (ConfigValue  o) {
660+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
657661    if  (! o.checkType <int >(log:  false )) {
658662      throw  ConfigSpecExtractionError (o);
659663    }
@@ -688,7 +692,7 @@ class EnumConfigSpec<CE extends Object?, RE extends Object?>
688692  });
689693
690694  @override 
691-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
695+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
692696    if  (! allowedValues.contains (o.value)) {
693697      if  (log) {
694698        _logger.severe (
@@ -704,7 +708,7 @@ class EnumConfigSpec<CE extends Object?, RE extends Object?>
704708  }
705709
706710  @override 
707-   ConfigValue <RE > _extractNode (ConfigValue  o) {
711+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
708712    if  (! allowedValues.contains (o.value)) {
709713      throw  ConfigSpecExtractionError (o);
710714    }
@@ -735,7 +739,7 @@ class BoolConfigSpec<RE> extends ConfigSpec<bool, RE> {
735739  });
736740
737741  @override 
738-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
742+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
739743    if  (! o.checkType <bool >(log:  log)) {
740744      return  false ;
741745    }
@@ -746,7 +750,7 @@ class BoolConfigSpec<RE> extends ConfigSpec<bool, RE> {
746750  }
747751
748752  @override 
749-   ConfigValue <RE > _extractNode (ConfigValue  o) {
753+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
750754    if  (! o.checkType <bool >(log:  false )) {
751755      throw  ConfigSpecExtractionError (o);
752756    }
@@ -784,7 +788,7 @@ class OneOfConfigSpec<TE extends Object?, RE extends Object?>
784788  });
785789
786790  @override 
787-   bool  _validateNode (ConfigValue  o, {bool  log =  true }) {
791+   bool  _validateNode (ConfigValue < Object ?>  o, {bool  log =  true }) {
788792    // Running first time with no logs. 
789793    for  (final  spec in  childConfigSpecs) {
790794      if  (spec._validateNode (o, log:  false )) {
@@ -806,7 +810,7 @@ class OneOfConfigSpec<TE extends Object?, RE extends Object?>
806810  }
807811
808812  @override 
809-   ConfigValue <RE > _extractNode (ConfigValue  o) {
813+   ConfigValue <RE > _extractNode (ConfigValue < Object ?>  o) {
810814    for  (final  spec in  childConfigSpecs) {
811815      if  (spec._validateNode (o, log:  false )) {
812816        return  o
0 commit comments