PropertySourcesPropertyResolver class

A concrete implementation of AbstractPropertyResolver that retrieves property values from a collection of PropertySources managed by a MutablePropertySources container.

This class supports resolving placeholders in property values and converting properties to specific types using a registered ConversionService.

Example usage:

final sources = MutablePropertySources();
sources.addPropertySource(MapPropertySource('config', {'app.name': 'Jetleaf'}));

final resolver = PropertySourcesPropertyResolver(sources);
print(resolver.getProperty('app.name')); // Jetleaf
print(resolver.getPropertyWithDefault('app.port', '8080')); // 8080

Placeholder resolution:

sources.addPropertySource(MapPropertySource('env', {
  'host': 'localhost',
  'url': 'http://${host}:8080'
}));

print(resolver.resolvePlaceholders('API: ${url}')); // API: http://localhost:8080
Inheritance

Constructors

PropertySourcesPropertyResolver(PropertySources? propertySources)
A concrete implementation of AbstractPropertyResolver that retrieves property values from a collection of PropertySources managed by a MutablePropertySources container.

Properties

hashCode → int
The hash code for this object.
no setterinherited
propertySources → PropertySources?
The collection of PropertySource instances from which this resolver retrieves property values.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

containsProperty(String key) → bool
Returns whether the given property key is defined.
override
convertValueIfNecessary<T>(Object value, Class<T>? targetType, [Class? source]) → T?
Convert a given value into the specified targetType if necessary.
inherited
getConversionService() → ConfigurableConversionService
Returns the ConfigurableConversionService used to perform type conversions.
inherited
getProperty(String key, [String? defaultValue]) → String?
Retrieves the value for the given property key, or null if not found.
override
getPropertyAs<T>(String key, Class<T> targetType, [T? defaultValue]) → T?
Retrieves and converts the value of key to the desired type T.
override
getPropertyAsRawString(String key) → String?
Retrieve the raw property value for the given key.
override
getRequiredProperty(String key) → String
Returns the property value for key, or throws IllegalStateException if the property is not defined.
inherited
getRequiredPropertyAs<T>(String key, Class<T> valueType) → T
Retrieves and converts the property key to type T, or throws IllegalStateException if missing or invalid.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolveNestedPlaceholders(String value) → String
Resolve nested placeholders within a given value.
inherited
resolvePlaceholders(String text) → String
Resolves #{...} placeholders in the input text using available properties.
inherited
resolveRequiredPlaceholders(String text) → String
Resolves #{...} placeholders in the input text using available properties.
inherited
setConversionService(ConfigurableConversionService service) → void
Replaces the underlying ConfigurableConversionService used for type conversions.
inherited
setEscapeCharacter(Character? escapeCharacter) → void
Sets the escape character used to ignore placeholder prefix and separator.
inherited
setIgnoreUnresolvableNestedPlaceholders(bool ignoreUnresolvableNestedPlaceholders) → void
Enables or disables ignoring unresolvable nested placeholders.
inherited
setPlaceholderPrefix(String placeholderPrefix) → void
Sets the prefix that identifies a placeholder in property values.
inherited
setPlaceholderSuffix(String placeholderSuffix) → void
Sets the suffix that identifies the end of a placeholder in property values.
inherited
setRequiredProperties(List<String> requiredProperties) → void
Sets the list of property names that are required to be present and non-null.
inherited
setValueSeparator(String? valueSeparator) → void
Sets the separator for default values within placeholders.
inherited
suggestions(String key) → List<String>
Returns a list of suggestions for the given key.
override
toString() → String
A string representation of this object.
inherited
validateRequiredProperties() → void
Validates that all required properties are present and non-null.
inherited

Operators

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