Interface DocConverter<T extends Annotation>

All Known Implementing Classes:
Author.Converter, CommandInfo.Converter, Error.Converter, RequiredPermissions.Converter
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 DocConverter<T extends Annotation>
Converts an annotation of the specified type T into a String to be collected with other conversions into a single String documenting a class or method representing a command for a bot.

These are the fundamental building blocks behind command doc annotations, and can be applied using the @ConvertedBy annotation:

    @ConvertedBy(MyCommandDocAnn.Converter.class)
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.ANNOTATION_TYPE)
     public @interface MyCommandDocAnn
     {
         String value();

         class Converter implements DocConverter<MyCommandDocAnn>
         {
             public String read(MyCommandDocAnn annotation)
             {
                 return "**"+annotation.value()+"**";
             }
         }
     }
 
It is also notably recommended you follow the standards for DocConverters listed below:
  • 1) read(java.lang.annotation.Annotation) should not throw any exceptions, nor otherwise halt a process due to one being thrown.
  • 2) When possible and practical, DocConverter implementations should be classes nested within the @interface they are used to convert (the example above demonstrates this).
  • 3) If at all possible, developers should avoid any variables to instantiate (IE: no-constructor).
Since:
2.0
Author:
Kaidan Gustave
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    read(T annotation)
    Returns a String processed from the contents of the provided Annotation.
  • Method Details

    • read

      String read(T annotation)
      Returns a String processed from the contents of the provided Annotation.
      Should never throw and/or encounter uncaught exceptions.
      Parameters:
      annotation - The annotation to process.
      Returns:
      A String processed from the Annotation provided.