Package org.incendo.cloud.caption
Interface CaptionFormatter<C,T>
- All Known Implementing Classes:
CaptionFormatter.PatternReplacingCaptionFormatter
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class -
Method Summary
Modifier and TypeMethodDescriptionformatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull List<@NonNull CaptionVariable> variables) Formats thecaption.formatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull CaptionVariable @NonNull ... variables) Formats thecaption.static <C> @NonNull CaptionFormatter<C, String> patternReplacing(@NonNull Pattern pattern) Returns a caption formatter that replaces the results from the givenpatternwith the values from the caption variables.static PatternReturns the pattern forplaceholderReplacing().static <C> @NonNull CaptionFormatter<C, String> Returns a caption formatter that replaces placeholders in the form of<placeholder>with the caption variables.
-
Method Details
-
patternReplacing
Returns a caption formatter that replaces the results from the givenpatternwith the values from the caption variables.The 1st capturing group will be used to determine the name of the variable to use for the replacement.
- Type Parameters:
C- the command sender type- Parameters:
pattern- the pattern- Returns:
- the formatter
-
placeholderReplacing
Returns a caption formatter that replaces placeholders in the form of<placeholder>with the caption variables.- Type Parameters:
C- the command sender type- Returns:
- the formatter
-
placeholderPattern
Returns the pattern forplaceholderReplacing(). Replaces variables in the<name>format.- Returns:
- the pattern for
placeholderReplacing()
-
formatCaption
default @NonNull T formatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull CaptionVariable @NonNull ... variables) Formats thecaption.- Parameters:
captionKey- the caption keyrecipient- the recipient of the messagecaption- the value of the captionvariables- the caption variables- Returns:
- the transformed message
-
formatCaption
@NonNull T formatCaption(@NonNull Caption captionKey, @NonNull C recipient, @NonNull String caption, @NonNull List<@NonNull CaptionVariable> variables) Formats thecaption.- Parameters:
captionKey- the caption keyrecipient- the recipient of the messagecaption- the value of the captionvariables- the caption variables- Returns:
- the transformed message
-