public interface PlaceholderText extends TextRepresentable
TextRepresentable
that can be used in Text
building methods
that represents a placeholder in text.
A PlaceholderText
is the collection of a PlaceholderParser
along with contextual data in the supplied PlaceholderContext
,
enabling its use in a Text
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
toText()
is called. Thus, any Text
object that is created
will reflect the time that the Text
object was requested, and not when
this object itself was created. It therefore follows that implementations must
not cache the result of toText()
unless it is known that the supplied
parser is not sensitive to the time of invocation.
Modifier and Type | Interface and Description |
---|---|
static interface |
PlaceholderText.Builder
A builder for
PlaceholderText objects. |
Modifier and Type | Method and Description |
---|---|
static PlaceholderText.Builder |
builder()
Gets a builder for creating
PlaceholderText . |
PlaceholderContext |
getContext()
|
PlaceholderParser |
getParser()
Gets the
PlaceholderParser that handles this placeholder. |
default Text |
toText()
Creates a
Text from the supplied PlaceholderParser in the
context of the supplied PlaceholderContext . |
applyTo
static PlaceholderText.Builder builder()
PlaceholderText
.PlaceholderText.Builder
PlaceholderContext getContext()
PlaceholderContext
PlaceholderParser getParser()
PlaceholderParser
that handles this placeholder.PlaceholderParser
default Text toText()
Text
from the supplied PlaceholderParser
in the
context of the supplied PlaceholderContext
.
This will always return a Text
object, however, if the parser
could not handle the provided context, this will be Text.EMPTY
.
toText
in interface TextRepresentable
Text