ConfigurationPropertySources class abstract final

Makes an environment find a property however a source spells it: a read of app.read-timeout also finds app.readTimeout, app.read_timeout or the variable APP_READTIMEOUT.

Without it the environment looks keys up exactly, so a value written readTimeout in YAML would be missed by @Value(r'${app.read-timeout}'). attach puts a ConfigurationPropertySourcesPropertySource first in the environment; from then on a read of a canonical name (lower case, - between words, like app.read-timeout or app.hosts[0]) through getProperty, @Value or ${...} finds every spelling. Sources are still asked in order, so the first source that has the property in any form wins. Names that are not canonical (app.readTimeout) are still looked up exactly.

Applications do not call it: ConfigDataEnvironment, and so SpringApplication, attaches it. Call attach for an environment you build and fill yourself.

// An environment built by hand that should match names like the
// application's does.
final environment = StandardEnvironment()
  ..propertySources.addFirst(
    MapPropertySource('app', {'app.readTimeout': '5s'}),
  );
ConfigurationPropertySources.attach(environment);
environment.getProperty('app.read-timeout'); // '5s'

Spring (Java):

ConfigurationPropertySources.attach(environment);
environment.getProperty("app.read-timeout");

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
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

attach(ConfigurableEnvironment environment) → void
Puts the relaxed source first in environment's sources, adding it or moving it back to the front. Calling it again is harmless.
getProperty(AbstractPropertySource<Object> source, ConfigurationPropertyName name) → Object?
The value of the property name in the single source, under any spelling, or null.
isAttached(ConfigurableEnvironment environment) → bool
Whether attach was called on environment (its relaxed source is present, wherever it now stands).
propertyNames(EnumerablePropertySource<Object> source) → Map<ConfigurationPropertyName, List<String>>
Every property of source as a ConfigurationPropertyName, each with the keys of source that spell it (in the source's order).

Constants

attachedPropertySourceName → const String
The name of the source attach adds: configurationProperties.