Interface PlaceholderComponent
-
- All Superinterfaces:
ComponentLike
public interface PlaceholderComponent extends ComponentLike
AComponentLike
that can be used inComponent
building methods that represents a placeholder in text.A
PlaceholderComponent
is the collection of aPlaceholderParser
along with contextual data in the suppliedPlaceholderContext
, enabling its use in aComponent
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, butPlaceholderParser.parse(PlaceholderContext)
is not called untilasComponent()
is called. Thus, anyComponent
object that is created will reflect the time that theComponent
object was requested, and not when this object itself was created. It therefore follows that implementations must not cache the result ofasComponent()
unless it is known that the supplied parser is not sensitive to the time of invocation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
PlaceholderComponent.Builder
A builder forPlaceholderComponent
objects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @NonNull Component
asComponent()
Creates aComponent
from the suppliedPlaceholderParser
in the context of the suppliedPlaceholderContext
.static PlaceholderComponent.Builder
builder()
Gets a builder for creatingPlaceholderComponent
.PlaceholderContext
context()
Gets thePlaceholderContext
that is to be supplied to thePlaceholderParser
to create theComponent
.PlaceholderParser
parser()
Gets thePlaceholderParser
that handles this placeholder.
-
-
-
Method Detail
-
builder
static PlaceholderComponent.Builder 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
default @NonNull Component 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
-
-