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

      Modifier and Type Method Description
      <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
      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

      • 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
      • 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