ConditionEvaluator class final

The ConditionEvaluator in Jetleaf is responsible for evaluating conditional annotations (e.g., Conditional, ConditionalOnClass, ConditionalOnPod) and determining whether a given source (class, method, or configuration) should be included in the Jetleaf application context.

It checks all conditions attached to a Source via annotations and ensures they are satisfied before including the source in the runtime.

Key Features:

  • Inspects annotations of a given Source.
  • Instantiates condition classes declared in the annotation.
  • Evaluates each condition against the current ConditionalContext.
  • Excludes sources if any condition does not match.

Usage Example:

final evaluator = ConditionEvaluator(
  registry,
  environment,
  podFactory,
  classLoader,
  runtimeProvider,
);

final shouldLoad = await evaluator.shouldInclude(mySource);

if (shouldLoad) {
  print('Source included!');
} else {
  print('Source excluded by conditions.');
}
Inheritance

Constructors

ConditionEvaluator(Environment environment, ConfigurableListablePodFactory podFactory)
The ConditionEvaluator in Jetleaf is responsible for evaluating conditional annotations (e.g., Conditional, ConditionalOnClass, ConditionalOnPod) and determining whether a given source (class, method, or configuration) should be included in the Jetleaf application context.

Properties

environment → Environment
Access application properties, system settings, and active profiles. Often used in condition evaluations to determine whether a pod should be activated.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
podFactory → ConfigurableListablePodFactory
Manages the lifecycle of pods in the current context. Developers can programmatically retrieve or configure pods.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addDefinition(PodDefinition definition) → void
Adds a PodDefinition to the list of unregistered definitions. Thread-safe and ensures uniqueness by removing existing instances before re-adding.
inherited
allConditionsMatch(Iterable<_AnnotatedCondition> conditions, Source source) Future<bool>
Checks whether all given conditions match the specified source asynchronously.
findAllConditionals(Source source) List<_ConditionalMatch>
Recursively finds all @Conditional annotations associated with a source.
getUnregisteredDefinitions() List<PodDefinition>
Returns an immutable snapshot of unregistered PodDefinition instances. External modifications do not affect the internal state.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
shouldInclude(Source source) Future<bool>
Evaluates whether the given source should be included in the Jetleaf context.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited