AbstractPropertyResolver class abstract

An abstract base implementation of ConfigurablePropertyResolver that provides common functionality for resolving property placeholders, type conversion, and required property validation.

This class centralizes configuration for:

  • Placeholder syntax (prefix, suffix, and value separators).
  • Escape characters for literal placeholders.
  • Integration with a ConfigurableConversionService for type-safe conversions.

Subclasses are expected to implement:

  • getProperty → Retrieve a property value as a string or typed object.
  • containsProperty → Check whether a property key exists.
  • Any additional accessors required for property resolution.

Responsibilities

  • Resolving nested placeholders in property values.
  • Delegating conversion to the active ConversionService.
  • Handling both optional and required property lookups.
  • Providing hooks for ignoring or enforcing unresolvable placeholders.

Example

class EnvPropertyResolver extends AbstractPropertyResolver {
  final Map<String, String> _env;

  EnvPropertyResolver(this._env);

  @override
  String? getProperty(String key) => _env[key];

  @override
  bool containsProperty(String key) => _env.containsKey(key);
}

void main() {
  final resolver = EnvPropertyResolver({'app.name': 'Jetleaf'});
  final value = resolver.resolveNestedPlaceholders('Welcome to \${app.name}');
  print(value); // "Welcome to Jetleaf"
}
Implemented types
Implementers

Constructors

AbstractPropertyResolver()
An abstract base implementation of ConfigurablePropertyResolver that provides common functionality for resolving property placeholders, type conversion, and required property validation.

Properties

hashCode → int
The hash code for this object.
no setterinherited
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.
getConversionService() → ConfigurableConversionService
Returns the ConfigurableConversionService used to perform type conversions.
override
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.
inherited
getPropertyAsRawString(String key) → String?
Retrieve the raw property value for the given key.
getRequiredProperty(String key) → String
Returns the property value for key, or throws IllegalStateException if the property is not defined.
override
getRequiredPropertyAs<T>(String key, Class<T> valueType) → T
Retrieves and converts the property key to type T, or throws IllegalStateException if missing or invalid.
override
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.
resolvePlaceholders(String text) → String
Resolves #{...} placeholders in the input text using available properties.
override
resolveRequiredPlaceholders(String text) → String
Resolves #{...} placeholders in the input text using available properties.
override
setConversionService(ConfigurableConversionService service) → void
Replaces the underlying ConfigurableConversionService used for type conversions.
override
setEscapeCharacter(Character? escapeCharacter) → void
Sets the escape character used to ignore placeholder prefix and separator.
override
setIgnoreUnresolvableNestedPlaceholders(bool ignoreUnresolvableNestedPlaceholders) → void
Enables or disables ignoring unresolvable nested placeholders.
override
setPlaceholderPrefix(String placeholderPrefix) → void
Sets the prefix that identifies a placeholder in property values.
override
setPlaceholderSuffix(String placeholderSuffix) → void
Sets the suffix that identifies the end of a placeholder in property values.
override
setRequiredProperties(List<String> requiredProperties) → void
Sets the list of property names that are required to be present and non-null.
override
setValueSeparator(String? valueSeparator) → void
Sets the separator for default values within placeholders.
override
suggestions(String key) → List<String>
Returns a list of suggestions for the given key.
inherited
toString() → String
A string representation of this object.
inherited
validateRequiredProperties() → void
Validates that all required properties are present and non-null.
override

Operators

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