ApplicationConfigurationProperty class abstract
A base class for defining structured and strongly typed configuration classes in the JetLeaf framework.
This replaces the need for @ConfigurationProperties annotations by requiring
subclasses to override the properties method. This method returns a
ApplicationConfigurationProperties instance, which contains metadata like the profile
(e.g. "dev", "prod") and source file name.
The JetLeaf framework uses this base class to automatically discover, validate, and inject environment-specific configurations at runtime.
๐ ๏ธ How to Use
- Create a class that extends ApplicationConfigurationProperty
- Implement the properties method, returning the profile and metadata
class DevConfig extends ConfigurationProperty {
final int port = 3000;
final bool debug = true;
@override
ConfigurationProperties properties() => ConfigurationProperties({
JetProperty.SERVER_PORT.copyWith(value: port),
JetProperty.DEBUG.copyWith(value: debug),
});
}
๐ฆ Default Profile Example
If your configuration is from application.dart, use the default profile:
class AppConfig extends ConfigurationProperty {
final int port = 8080;
final bool secure = false;
@override
ConfigurationProperties properties() => ConfigurationProperties.empty(); // default
}
๐ What This Enables
- ๐งญ Automatic profile resolution (e.g.,
application_dev.dartโdev) - ๐งช Type-safe property validation via JetProperty
- ๐งฐ Code generation or runtime scanning for all configuration providers
- โ No need for custom annotations or reflection
๐งฑ Why You Must Extend ApplicationConfigurationProperty
- Allows Jet to discover configuration classes at runtime
- Enables profile-specific overrides and conditional loading
- Encourages typed, expressive configuration definitions
๐ Switching Configurations by Profile
Jet uses the profile field from ApplicationConfigurationProperties to decide
which config to apply. For example:
ConfigurationProperties({JetProperty.PROFILE.copyWith(value: 'dev')})
will be used when application_dev.dart is the active environment.
โ Summary
| Feature | Description |
|---|---|
| Profile Support | Built-in via application_dev.dart |
| Source Metadata | Optional, for debugging or documentation |
| Annotation-Free | No annotation required, uses Dart idioms |
| Type Safety | Powered by JetProperty and runtime validation |
See also: ApplicationConfigurationProperties
Constructors
Properties
- hashCode โ int
-
The hash code for this object.
no setterinherited
- runtimeType โ Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) โ dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
properties(
) โ ApplicationConfigurationProperties -
Returns a ApplicationConfigurationProperties instance that contains metadata
such as the active profile (
default,dev,prod, etc.) and optional source info (e.g., file name or module origin). -
toString(
) โ String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) โ bool -
The equality operator.
inherited