ConfigurationProperty 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 ConfigurationProperties 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 ConfigurationProperty
  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 ConfigurationProperty

  • 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 ConfigurationProperties 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: ConfigurationProperties

Constructors

ConfigurationProperty()

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() β†’ ConfigurationProperties
Returns a ConfigurationProperties 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