PropertySource<T> class
abstract
A base abstraction representing a source of key-value properties, such as maps, environment variables, or configuration files.
Each PropertySource has a unique name and a backing source of type T
,
which holds the actual data. Concrete subclasses implement lookup behavior
using containsProperty and getProperty.
Common implementations include:
This abstraction allows a flexible property resolution system where multiple sources can be layered and resolved by a resolver such as PropertySourcesPropertyResolver.
Example usage:
class MyEnvSource extends PropertySource<Map<String, String>> {
MyEnvSource(String name, Map<String, String> source) : super(name, source);
@override
bool containsProperty(String name) => source.containsKey(name);
@override
Object? getProperty(String name) => source[name];
}
final env = MyEnvSource('env', {'APP_ENV': 'prod'});
print(env.getProperty('APP_ENV')); // prod
- Implementers
- Annotations
-
- @Generic.new(PropertySource)
Constructors
- PropertySource(String name, T source)
- A base abstraction representing a source of key-value properties, such as maps, environment variables, or configuration files.
- PropertySource.named(String name)
- A base abstraction representing a source of key-value properties, such as maps, environment variables, or configuration files.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- name → String
-
The unique name that identifies this property source.
Typically used for logging, debugging, and source resolution order.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → T
-
The underlying object that holds the raw property data.
final
Methods
-
containsProperty(
String name) → bool -
Returns
true
if this property source contains the givenname
. -
equalizedProperties(
) → List< Object?> -
Mixin-style contract for value-based equality,
hashCode
, andtoString
. -
getName(
) → String - Returns the name of this property source.
-
getProperty(
String name) → Object? -
Retrieves the value associated with the given
name
, ornull
if not present. -
getSource(
) → T - Returns the underlying source object.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
namedStatic(
String name) → PropertySource - A base abstraction representing a source of key-value properties, such as maps, environment variables, or configuration files.