- Type Parameters:
T
- The type of argument that is parsed.
- All Superinterfaces:
ArgumentParser<Attachment,
,T> AttachmentDataParser<T>
,AttachmentParser<T>
,AttachmentParserStages.Parser<T>
,AttachmentParserStages.Validator
,BiFunction<CommandContext,
,Attachment, Mono<T>> ParserFunction<Attachment,
T>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface TextFileParser<T extends @NonNull Object>
extends AttachmentDataParser<T>
Parses an argument from an attached text file.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.AttachmentDataParser
AttachmentDataParser.Resources
Nested classes/interfaces inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
ParserFunction.PostParser<R extends @NonNull Object,
I extends @NonNull Object, T extends @NonNull Object, P1 extends @NonNull ParserFunction<R, I>, P2 extends @NonNull ParserFunction<I, T>> -
Field Summary
Fields inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.AttachmentDataParser
GLOBAL_RESOURCES
-
Method Summary
Modifier and TypeMethodDescriptionparse
(CommandContext context, String content) Parses the content of the attachment file.parse
(CommandContext context, reactor.netty.http.client.HttpClientResponse response, reactor.netty.ByteBufMono body) Parses the response from fetching the attachment file into the corresponding value.default void
validate
(Attachment attachment) Validates that the attachment is appropriate prior to fetching it.Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ArgumentParser
parse
Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.AttachmentDataParser
getHttpClient, getUrl, maxSize, parseArgument, validateRaw
Methods inherited from interface java.util.function.BiFunction
andThen
Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
apply, then
-
Method Details
-
validate
Description copied from interface:AttachmentParserStages.Validator
Validates that the attachment is appropriate prior to fetching it.- Specified by:
validate
in interfaceAttachmentDataParser<T extends @NonNull Object>
- Specified by:
validate
in interfaceAttachmentParserStages.Validator
- Parameters:
attachment
- The attachment to validate.- Throws:
InvalidArgumentException
- if the attachment is not valid.- Implementation Requirements:
- Verifies that the attachment is a text file (any type of MIME text file, not necessarily .txt).
-
parse
@SideEffectFree Mono<T> parse(CommandContext context, String content) throws InvalidArgumentException Parses the content of the attachment file.- Parameters:
context
- The execution context.content
- The attachment content.- Returns:
- A Mono that issues the parsed argument. If the content is invalid, it may
fail with a
InvalidArgumentException
. - Throws:
InvalidArgumentException
- if the given content is not valid.
-
parse
default Mono<T> parse(CommandContext context, reactor.netty.http.client.HttpClientResponse response, reactor.netty.ByteBufMono body) throws InvalidArgumentException Description copied from interface:AttachmentParserStages.Parser
Parses the response from fetching the attachment file into the corresponding value.- Specified by:
parse
in interfaceAttachmentParserStages.Parser<T extends @NonNull Object>
- Parameters:
context
- The execution context.response
- The response metadata.body
- The response body.- Returns:
- A Mono that issues the parsed argument. If the content is invalid, it may
fail with a
InvalidArgumentException
. - Throws:
InvalidArgumentException
- if the given response is not valid.- Implementation Requirements:
- Parses the attachment file content using
parse(CommandContext, String)
.
-