resolvePlaceholder abstract method
Strategy interface for resolving placeholder values in configuration strings.
A PlaceholderResolver
is typically used in systems like property resolvers,
YAML or .properties
processors, and templating engines to resolve
values like #{host}
or #{user.name}
.
If the placeholder cannot be resolved, this interface allows returning null
to indicate that no replacement is to be made.
Example
class MapPlaceholderResolver implements PlaceholderResolver {
final Map<String, String> values;
MapPlaceholderResolver(this.values);
@override
String? resolvePlaceholder(String placeholderName) => values[placeholderName];
}
final resolver = MapPlaceholderResolver({'port': '8080'});
print(resolver.resolvePlaceholder('port')); // 8080
Resolves the supplied placeholderName
to its replacement value.
Returns null
if no replacement should be made.
This method is typically called by a property placeholder parser or configuration string processor.
placeholderName
: The name of the placeholder (without#{
).- Returns: The replacement value, or
null
if unresolved.
Implementation
/// Resolves the supplied [placeholderName] to its replacement value.
///
/// Returns `null` if no replacement should be made.
///
/// This method is typically called by a property placeholder parser or
/// configuration string processor.
///
/// - [placeholderName]: The name of the placeholder (without `#{`).
/// - Returns: The replacement value, or `null` if unresolved.
String? resolvePlaceholder(String placeholderName);