Class AnnotationParser<C>
- java.lang.Object
-
- cloud.commandframework.annotations.AnnotationParser<C>
-
- Type Parameters:
C- Command sender type
public final class AnnotationParser<C> extends java.lang.ObjectParser that parses class instancescommands
-
-
Constructor Summary
Constructors Constructor Description AnnotationParser(@NonNull cloud.commandframework.CommandManager<C> manager, @NonNull java.lang.Class<C> commandSenderClass, @NonNull java.util.function.Function<@NonNull cloud.commandframework.arguments.parser.ParserParameters,@NonNull cloud.commandframework.meta.CommandMeta> metaMapper)Construct a new annotation parser
-
Method Summary
Modifier and Type Method Description <T> @NonNull java.util.Collection<@NonNull cloud.commandframework.Command<C>>parse(@NonNull T instance)Scan a class instance ofCommandMethodannotations and attempt to compile them intoCommandinstances<A extends java.lang.annotation.Annotation>
voidregisterAnnotationMapper(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.Function<@NonNull A,@NonNull cloud.commandframework.arguments.parser.ParserParameters> mapper)Register an annotation mapper<A extends java.lang.annotation.Annotation>
voidregisterPreprocessorMapper(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.Function<A,java.util.function.BiFunction<@NonNull cloud.commandframework.context.CommandContext<C>,@NonNull java.util.Queue<@NonNull java.lang.String>,@NonNull cloud.commandframework.arguments.parser.ArgumentParseResult<java.lang.Boolean>>> preprocessorMapper)Register a preprocessor mapper
-
-
-
Constructor Detail
-
AnnotationParser
public AnnotationParser(@NonNull cloud.commandframework.CommandManager<C> manager, @NonNull java.lang.Class<C> commandSenderClass, @NonNull java.util.function.Function<@NonNull cloud.commandframework.arguments.parser.ParserParameters,@NonNull cloud.commandframework.meta.CommandMeta> metaMapper)
Construct a new annotation parser- Parameters:
manager- Command manager instancecommandSenderClass- Command sender classmetaMapper- Function that is used to createCommandMetainstances from annotations on the command methods. These annotations will be mapped toParserParameter. Mappers for the parser parameters can be registered usingregisterAnnotationMapper(Class, Function)
-
-
Method Detail
-
registerAnnotationMapper
public <A extends java.lang.annotation.Annotation> void registerAnnotationMapper(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.Function<@NonNull A,@NonNull cloud.commandframework.arguments.parser.ParserParameters> mapper)Register an annotation mapper- Type Parameters:
A- Annotation type- Parameters:
annotation- Annotation classmapper- Mapping function
-
registerPreprocessorMapper
public <A extends java.lang.annotation.Annotation> void registerPreprocessorMapper(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.Function<A,java.util.function.BiFunction<@NonNull cloud.commandframework.context.CommandContext<C>,@NonNull java.util.Queue<@NonNull java.lang.String>,@NonNull cloud.commandframework.arguments.parser.ArgumentParseResult<java.lang.Boolean>>> preprocessorMapper)Register a preprocessor mapper- Type Parameters:
A- Annotation type- Parameters:
annotation- Annotation classpreprocessorMapper- Preprocessor mapper
-
parse
public <T> @NonNull java.util.Collection<@NonNull cloud.commandframework.Command<C>> parse(@NonNull T instance)
Scan a class instance ofCommandMethodannotations and attempt to compile them intoCommandinstances- Type Parameters:
T- Type of the instance- Parameters:
instance- Instance to scan- Returns:
- Collection of parsed annotations
-
-