Interface PlaceholderComponent
-
- All Superinterfaces:
ComponentLike
public interface PlaceholderComponent extends ComponentLike
AComponentLikethat can be used inComponentbuilding methods that represents a placeholder in text.A
PlaceholderComponentis the collection of aPlaceholderParseralong with contextual data in the suppliedPlaceholderContext, enabling its use in aComponentobject.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
PlaceholderContextis fixed when this object is created, butPlaceholderParser.parse(PlaceholderContext)is not called untilasComponent()is called. Thus, anyComponentobject that is created will reflect the time that theComponentobject 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 interfacePlaceholderComponent.BuilderA builder forPlaceholderComponentobjects.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default @NonNull ComponentasComponent()Creates aComponentfrom the suppliedPlaceholderParserin the context of the suppliedPlaceholderContext.static PlaceholderComponent.Builderbuilder()Gets a builder for creatingPlaceholderComponent.PlaceholderContextcontext()Gets thePlaceholderContextthat is to be supplied to thePlaceholderParserto create theComponent.PlaceholderParserparser()Gets thePlaceholderParserthat handles this placeholder.
-
-
-
Method Detail
-
builder
static PlaceholderComponent.Builder builder()
Gets a builder for creatingPlaceholderComponent.- Returns:
- A
PlaceholderComponent.Builder
-
context
PlaceholderContext context()
Gets thePlaceholderContextthat is to be supplied to thePlaceholderParserto create theComponent.- Returns:
- The
PlaceholderContext
-
parser
PlaceholderParser parser()
Gets thePlaceholderParserthat handles this placeholder.- Returns:
- The
PlaceholderParser
-
asComponent
default @NonNull Component asComponent()
Creates aComponentfrom the suppliedPlaceholderParserin the context of the suppliedPlaceholderContext.This will always return a
Componentobject, however, if the parser could not handle the provided context, this will beComponent.empty().- Specified by:
asComponentin interfaceComponentLike- Returns:
- The parsed
Component
-
-