SimplePlaceholderPart class
A PlaceholderPart that represents a basic placeholder expression with an optional fallback.
This class is used to resolve expressions like #{name}
or #{name:defaultValue}
where name
is the key to resolve, and defaultValue
is an optional fallback.
Example usage:
var part = SimplePlaceholderPart(r'#{user}', 'user', null);
var result = part.resolve(context); // resolved value or throws
The resolution process attempts the following:
- Tries to resolve the full
text()
(e.g.,#{user}
) recursively. - If unsuccessful, tries to resolve just the
key
(e.g.,user
). - If still unresolved, uses the
fallback
if provided. - Otherwise, it calls PlaceholderPartResolutionContext.handleUnresolvablePlaceholder.
This class extends PlaceholderAbstractPart, which provides shared recursive resolution logic.
- Inheritance
-
- Object
- PlaceholderAbstractPart
- SimplePlaceholderPart
Constructors
- SimplePlaceholderPart(String text, String key, String? fallback)
- A PlaceholderPart that represents a basic placeholder expression with an optional fallback.
Properties
- fallback → String?
-
An optional fallback value to use if the placeholder cannot be resolved.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → String
-
The raw key of the placeholder (e.g.,
user
in#{user}
).final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolve(
PlaceholderPartResolutionContext resolutionContext) → String -
Represents a segment or fragment of a placeholder expression.
override
-
resolveRecursively(
PlaceholderPartResolutionContext resolutionContext, String key) → String? -
Recursively resolves the placeholder identified by
key
using the providedresolutionContext
.inherited -
text(
) → String -
Returns the raw textual representation of this part.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited