PropertySource<T>.named constructor
PropertySource<T>.named (
- String name
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
Creates a named property source without any backing source. Useful for stubs or symbolic sources.
Implementation
PropertySource.named(String name) : this(name, Object() as T);