ConditionalOnClass class

The ConditionalOnClass annotation in Jetleaf allows developers to conditionally process a class or method only when certain classes are present in the runtime classpath.

This is useful for optional dependencies, integration with external libraries, or conditional configuration based on class availability.

Usage Examples:

// Only load HTTP client configuration if HttpClient exists
@ConditionalOnClass(value: [ClassType<HttpClient>()])
class HttpClientAutoConfig {}

// Use fully qualified class names to avoid compilation errors
@ConditionalOnClass(name: ['package:jetleaf/example/jetleaf_example.dart.LoggingService'])
class OptionalFeatureConfig {}
Annotations
  • @Conditional([ClassType<OnClassCondition>()])
  • @Target.new({TargetKind.classType, TargetKind.method})

Constructors

ConditionalOnClass({List<ClassType<Object>> value = const [], List<String> names = const []})
The ConditionalOnClass annotation in Jetleaf allows developers to conditionally process a class or method only when certain classes are present in the runtime classpath.
const

Properties

annotationType Type
Returns the annotation _type of this annotation.
no setter
hashCode int
The hash code for this object.
no setterinherited
names List<String>
ClassType names (fully qualified) that must be present at runtime.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value List<ClassType<Object>>
Classes that must be present at runtime.
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