ConditionalOnMissingPod class

The ConditionalOnMissingPod annotation in Jetleaf allows developers to conditionally process a class or method only when certain pods are not present in the application context.

This is particularly useful for providing fallback configurations or alternative beans/pods when expected ones are absent.

Key Features:

  • Ensures a pod is only loaded if another pod type or name is missing.
  • Supports ignoring specific annotations when determining pod presence.
  • Supports ignoring entire pod types to avoid conflicts with infrastructure.

Usage Examples:

// Only load an embedded database when no DataSource is present
@ConditionalOnMissingPod(types: [ClassType<DataSource>()])
class EmbeddedDatabaseConfig {}

// Provide a fallback service if a specific pod name is missing
@ConditionalOnMissingPod(name: ['myCustomService'])
class FallbackServiceConfig {}

// Ignore infrastructure pods while checking for missing dependencies
@ConditionalOnMissingPod(
  types: [ClassType<MyService>()],
  ignoredTypes: [ClassType<DataSource>()],
)
class AlternativeServiceConfig {}

This ensures Jetleaf applications remain flexible by enabling conditional fallbacks and context-aware configuration.

Annotations
  • @Conditional([ClassType<OnPodCondition>()])
  • @Target.new({TargetKind.classType, TargetKind.method})

Constructors

ConditionalOnMissingPod({List<ClassType<Object>> types = const [], List<String> names = const [], List<ClassType<Object>> ignoredTypes = const []})
The ConditionalOnMissingPod annotation in Jetleaf allows developers to conditionally process a class or method only when certain pods are not present in the application context.
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setter
hashCode int
The hash code for this object.
no setterinherited
ignoredTypes List<ClassType<Object>>
Types to ignore while searching for conflicting pods.
final
names List<String>
Pod names that must not be present in the context.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
types List<ClassType<Object>>
Pod types that must not be present in the context.
final

Methods

equalizedProperties() List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
equals(Object other) bool
Checks whether the given object is logically equivalent to this annotation.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
Returns a string representation of this annotation.

Operators

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