Class AnnotationParser<C>

  • Type Parameters:
    C - Command sender type

    public final class AnnotationParser<C>
    extends java.lang.Object
    Parser that parses class instances commands
    • 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-argument parameters into CommandMethod annotated methods
      <T> @NonNull java.util.Collection<@NonNull cloud.commandframework.Command<C>> parse​(@NonNull T instance)
      Scan a class instance of CommandMethod annotations and attempt to compile them into Command instances
      <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
      <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.
      <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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 instance
        commandSenderClass - Command sender class
        metaMapper - Function that is used to create CommandMeta instances from annotations on the command methods. These annotations will be mapped to ParserParameter. Mappers for the parser parameters can be registered using registerAnnotationMapper(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 a Command.Builder after 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 to
        builderModifier - 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 class
        mapper - 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 class
        preprocessorMapper - Preprocessor mapper
      • getParameterInjectorRegistry

        public @NonNull cloud.commandframework.annotations.injection.ParameterInjectorRegistry<C> getParameterInjectorRegistry()
        Get the parameter injector registry instance that is used to inject non-argument parameters into CommandMethod annotated methods
        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 of CommandMethod annotations and attempt to compile them into Command instances
        Type Parameters:
        T - Type of the instance
        Parameters:
        instance - Instance to scan
        Returns:
        Collection of parsed annotations