- Type Parameters:
T- The type of argument that is provided.
- All Superinterfaces:
ArgumentParser<Attachment,,T> AttachmentParser<T>,AttachmentParserStages.Parser<T>,AttachmentParserStages.Validator,BiFunction<CommandContext,,Attachment, Mono<T>> ParserFunction<Attachment,T>
- All Known Subinterfaces:
TextFileParser<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 AttachmentDataParser<T extends @NonNull Object>
extends AttachmentParser<T>, AttachmentParserStages.Validator, AttachmentParserStages.Parser<T>
Parses received attachment arguments into their actual value.
- Since:
- 1.0
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classResources used by an instance.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
FieldsModifier and TypeFieldDescriptionstatic final AttachmentDataParser.ResourcesResources used by all instances. -
Method Summary
Modifier and TypeMethodDescriptiondefault reactor.netty.http.client.HttpClientgetHttpClient(CommandContext context) Determines the HTTP client to use to fetch the attachment.default StringgetUrl(Attachment value) Obtains the URL to download the attachment from.default @org.checkerframework.common.value.qual.IntRange(from=0L) intmaxSize()Retrieves the maximum size (in bytes) that the attachment may have.parseArgument(CommandContext context, Attachment raw) Parses the given raw argument from the user into the corresponding value.default voidvalidate(Attachment attachment) Validates that the attachment is appropriate prior to fetching it.default AttachmentvalidateRaw(Attachment raw) Validates the raw value before parsing.Methods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ArgumentParser
parseMethods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.AttachmentParserStages.Parser
parseMethods inherited from interface java.util.function.BiFunction
andThenMethods inherited from interface dev.sympho.modular_commands.api.command.parameter.parse.ParserFunction
apply, then
-
Field Details
-
GLOBAL_RESOURCES
Resources used by all instances.
-
-
Method Details
-
validate
Description copied from interface:AttachmentParserStages.ValidatorValidates that the attachment is appropriate prior to fetching it.- Specified by:
validatein interfaceAttachmentParserStages.Validator- Parameters:
attachment- The attachment to validate.- Throws:
InvalidArgumentException- if the attachment is not valid.- Implementation Requirements:
- The default is a no-op.
-
maxSize
Retrieves the maximum size (in bytes) that the attachment may have.- Returns:
- The maximum size.
- Implementation Requirements:
- The default is
Integer.MAX_VALUE.
-
validateRaw
Description copied from interface:ArgumentParserValidates the raw value before parsing.- Specified by:
validateRawin interfaceArgumentParser<Attachment,T extends @NonNull Object> - Parameters:
raw- The raw value.- Returns:
- The raw value.
- Throws:
InvalidArgumentException- if the value is invalid.
-
getUrl
Obtains the URL to download the attachment from.- Parameters:
value- The attachment.- Returns:
- The URL to download from.
- Implementation Requirements:
- Defaults to the non-proxy URL.
-
getHttpClient
Determines the HTTP client to use to fetch the attachment.- Parameters:
context- The execution context.- Returns:
- The HTTP client to use.
- Implementation Requirements:
- The default delegates to
GLOBAL_RESOURCES.AttachmentDataParser.Resources.getClientGetter().
-
parseArgument
default Mono<T> parseArgument(CommandContext context, Attachment raw) throws InvalidArgumentException Description copied from interface:ArgumentParserParses the given raw argument from the user into the corresponding value.- Specified by:
parseArgumentin interfaceArgumentParser<Attachment,T extends @NonNull Object> - Parameters:
context- The execution context.raw- The raw argument received from the user.- Returns:
- A Mono that issues the parsed argument. If the raw value is invalid, it may
fail with a
InvalidArgumentException. - Throws:
InvalidArgumentException- if the given argument is not a valid value.- Implementation Requirements:
- Fetches the attachment from the
URLusing a client obtained byHttpClient.create()then delegates toAttachmentParserStages.Parser.parse(CommandContext, HttpClientResponse, ByteBufMono).
-