resolvePlaceholders static method

String resolvePlaceholders(
  1. String text
)

Utility class for resolving #{...}-style placeholders within strings using system properties or environment variables.

This class provides static methods to:

  • Resolve system placeholders like #{user.name}
  • Configure whether unresolved placeholders should throw or be ignored

It supports default value resolution using the colon : separator, and escaping using the backslash \.

Example (strict resolution)

final result = SystemPropertyUtils.resolvePlaceholders('Hello #{USER}');
print(result); // Throws if USER is not found

Example (lenient resolution)

final result = SystemPropertyUtils.resolvePlaceholdersWithPlaceholder(
  'Hello #{USER:Guest}',
  true,
);
print(result); // Hello Guest

Resolves all #{...} placeholders in text using system properties and environment variables.

This method is strict: if a placeholder cannot be resolved and no default value is specified, an IllegalArgumentException will be thrown.

Example

final result = SystemPropertyUtils.resolvePlaceholders('Hello #{USER}');

Implementation

static String resolvePlaceholders(String text) {
  return resolvePlaceholdersWithPlaceholder(text, false);
}