findMostApplicable method

Rule? findMostApplicable({
  1. required String path,
  2. PrecedenceStrategy comparisonMethod = PrecedenceStrategy.defaultStrategy,
})

Taking a path, gets the Rules that pertain to it, and returns the Rule that has precedence over the other rules.

Implementation

Rule? findMostApplicable({
  required String path,
  PrecedenceStrategy comparisonMethod = PrecedenceStrategy.defaultStrategy,
}) {
  final comparisonFunction = _ruleComparisonFunctions[comparisonMethod]!;

  final applicableRules = findApplicable(path: path);
  if (applicableRules.isEmpty) {
    return null;
  }

  return applicableRules.reduce(comparisonFunction);
}