conditionsMatch function
bool
conditionsMatch(
- Iterable<
Condition> conditions, - ConditionContext context, {
- ConfigurationPhase? phase,
- String? source,
Whether every one of conditions matches; the context calls it for
each definition while the modules load.
In phase, a ConfigurationCondition of the other phase is not
evaluated and counts as matching; without a phase every condition is
evaluated. Evaluation stops at the first condition that does not
match. With a source, each outcome is recorded when context is a
ConditionEvaluationRecorder. Spring's ConditionEvaluator.shouldSkip,
inverted.
conditionsMatch(definition.conditions, context,
phase: ConfigurationPhase.parseConfiguration);
Implementation
bool conditionsMatch(
Iterable<Condition> conditions,
ConditionContext context, {
ConfigurationPhase? phase,
String? source,
}) {
for (final condition in conditions) {
final skipped = switch (condition) {
ConfigurationCondition(:final configurationPhase) =>
phase != null && configurationPhase != phase,
_ => false,
};
final matches = switch (condition) {
_ when skipped => true,
final ConditionGroup group when phase != null => group.matchesIn(
context,
phase,
),
_ => condition.matches(context),
};
// Outcomes go to the evaluation report under [source]; a group
// records its own conditions under its key.
if (source != null &&
!skipped &&
condition is! ConditionGroup &&
context is ConditionEvaluationRecorder) {
(context as ConditionEvaluationRecorder).recordCondition(
source,
condition,
matches,
);
}
if (!matches) {
return false;
}
}
return true;
}