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

  1. Create a class that extends ApplicationConfigurationProperty
  2. 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

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