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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @NonNull cloud.commandframework.annotations.injection.ParameterInjectorRegistry<C>getParameterInjectorRegistry()Get the parameter injector registry instance that is used to inject non-argumentparameters intoCommandMethodannotatedmethods<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>
voidregisterBuilderModifier(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.BiFunction<A,cloud.commandframework.Command.Builder<C>,cloud.commandframework.Command.Builder<C>> builderModifier)Register a builder modifier for a specific annotation.<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
-
registerBuilderModifier
public <A extends java.lang.annotation.Annotation> void registerBuilderModifier(@NonNull java.lang.Class<A> annotation, @NonNull java.util.function.BiFunction<A,cloud.commandframework.Command.Builder<C>,cloud.commandframework.Command.Builder<C>> builderModifier)Register a builder modifier for a specific annotation. The builder modifiers are allowed to act on aCommand.Builderafter all arguments have been added to the builder. This allows for modifications of the builder instance before the command is registered to the command manager.- Type Parameters:
A- Annotation type- Parameters:
annotation- Annotation (class) that the builder modifier reacts tobuilderModifier- Modifier that acts on the given annotation and the incoming builder. Command builders are immutable, so the modifier should return the instance of the command builder that is returned as a result of any operation on the builder
-
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
-
getParameterInjectorRegistry
public @NonNull cloud.commandframework.annotations.injection.ParameterInjectorRegistry<C> getParameterInjectorRegistry()
Get the parameter injector registry instance that is used to inject non-argumentparameters intoCommandMethodannotatedmethods- Returns:
- Parameter injector registry
- Since:
- 1.2.0
-
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
-
-