SystemPropertyPlaceholderResolver class
A PlaceholderResolver implementation that resolves placeholders using system properties and environment variables.
It first attempts to resolve the placeholder name from
System.getProperty. If not found, it then tries System.getEnvVar.
If both fail, it returns null and logs the error to System.err.
This is useful when resolving configuration values that may be defined via system-level properties or OS-level environment variables.
Example
final text = 'Hello \#{USER}';
final resolver = SystemPropertyPlaceholderResolver(text);
final value = resolver.resolvePlaceholder('USER');
print(value); // e.g., 'francis'
Can be used with PropertyPlaceholderHelper to perform substitution:
final helper = PropertyPlaceholderHelper('\#{', '}');
final result = helper.replacePlaceholdersWithResolver(text, resolver.resolvePlaceholder);
- Implemented types
Constructors
- SystemPropertyPlaceholderResolver(String text)
- A PlaceholderResolver implementation that resolves placeholders using system properties and environment variables.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolvePlaceholder(
String placeholderName) → String? -
Strategy interface for resolving placeholder values in configuration strings.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited