Interface PlaceholderComponent
- All Superinterfaces:
ComponentLike
ComponentLike
that can be used in Component
building methods
that represents a placeholder in text.
A PlaceholderComponent
is the collection of a
PlaceholderParser
along with contextual data in the supplied
PlaceholderContext
, enabling its use in a Component
object.
Such placeholders will generally be built from tokenized strings, however these objects make no assumption about the format of text templating. Such a system can therefore be used by other templating engines without conforming to a particular standard.
The PlaceholderContext
is fixed when this object is created, but
PlaceholderParser.parse(PlaceholderContext)
is not called until
asComponent()
is called. Thus, any Component
object that is
created will reflect the time that the Component
object was
requested, and not when this object itself was created. It therefore follows
that implementations must not cache the result of asComponent()
unless it is known that the supplied parser is not sensitive
to the time of invocation.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A builder forPlaceholderComponent
objects. -
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull Component
Creates aComponent
from the suppliedPlaceholderParser
in the context of the suppliedPlaceholderContext
.static PlaceholderComponent.Builder
builder()
Gets a builder for creatingPlaceholderComponent
.context()
Gets thePlaceholderContext
that is to be supplied to thePlaceholderParser
to create theComponent
.parser()
Gets thePlaceholderParser
that handles this placeholder.
-
Method Details
-
builder
Gets a builder for creatingPlaceholderComponent
.- Returns:
- A
PlaceholderComponent.Builder
-
context
PlaceholderContext context()Gets thePlaceholderContext
that is to be supplied to thePlaceholderParser
to create theComponent
.- Returns:
- The
PlaceholderContext
-
parser
PlaceholderParser parser()Gets thePlaceholderParser
that handles this placeholder.- Returns:
- The
PlaceholderParser
-
asComponent
Creates aComponent
from the suppliedPlaceholderParser
in the context of the suppliedPlaceholderContext
.This will always return a
Component
object, however, if the parser could not handle the provided context, this will beComponent.empty()
.- Specified by:
asComponent
in interfaceComponentLike
- Returns:
- The parsed
Component
-