Class RegexPreprocessor<C>
java.lang.Object
org.incendo.cloud.component.preprocessor.RegexPreprocessor<C>
- Type Parameters:
C- command sender type
- All Implemented Interfaces:
ComponentPreprocessor<C>
@API(status=STABLE)
public final class RegexPreprocessor<C>
extends Object
implements ComponentPreprocessor<C>
Command preprocessor that filters based on regular expressions
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classException thrown when input fails regex matching inRegexPreprocessor -
Method Summary
Modifier and TypeMethodDescriptionstatic <C> @NonNull RegexPreprocessor<C> Create a new preprocessor usingStandardCaptionKeys.ARGUMENT_PARSE_FAILURE_REGEXas the failure captionstatic <C> @NonNull RegexPreprocessor<C> Create a new preprocessorpreprocess(@NonNull CommandContext<C> context, @NonNull CommandInput commandInput) Pre-processes the associated component.
-
Method Details
-
of
Create a new preprocessor usingStandardCaptionKeys.ARGUMENT_PARSE_FAILURE_REGEXas the failure caption- Type Parameters:
C- Command sender type- Parameters:
pattern- Regular expression- Returns:
- Preprocessor instance
-
of
public static <C> @NonNull RegexPreprocessor<C> of(@NonNull String pattern, @NonNull Caption failureCaption) Create a new preprocessor- Type Parameters:
C- Command sender type- Parameters:
pattern- Regular expressionfailureCaption- Caption sent when the input is invalid- Returns:
- Preprocessor instance
-
preprocess
public @NonNull ArgumentParseResult<Boolean> preprocess(@NonNull CommandContext<C> context, @NonNull CommandInput commandInput) Description copied from interface:ComponentPreprocessorPre-processes the associated component.If the preprocessor fails then the command parsing will fail immediately.
- Specified by:
preprocessin interfaceComponentPreprocessor<C>- Parameters:
context- the command contextcommandInput- the current command input- Returns:
- the result
-