SystemPropertyPlaceholderResolver constructor

SystemPropertyPlaceholderResolver(
  1. String text
)

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);

Creates a resolver instance for the given placeholder-containing text.

Implementation

SystemPropertyPlaceholderResolver(this.text);