Class AnnotationParser<S extends Source>

java.lang.Object
studio.mevera.imperat.annotations.base.AnnotationParser<S>
Type Parameters:
S - the command-sender valueType

public abstract class AnnotationParser<S extends Source> extends Object
Represents a class with a single responsibility of parsing annotated command classes and translating/converting them into Command POJOs then registering them using Imperat
  • Field Details

  • Method Details

    • defaultParser

      public static <S extends Source> AnnotationParser<S> defaultParser(@NotNull @NotNull Imperat<S> dispatcher)
    • parseCommandClass

      public abstract <T> void parseCommandClass(T instance)
      Parses annotated command class of valueType AnnotationParser into Command then register it using Imperat
      Type Parameters:
      T - the valueType of annotated command class to parse
      Parameters:
      instance - the instance of the command class
    • parseThrowableHandlerClass

      public abstract <T> void parseThrowableHandlerClass(T instance)
      Parses annotated throwable handling class into a set of ThrowableResolver that are automatically injected into the instance of Imperat that you're using.
      Type Parameters:
      T - the type of the instance of the throwable-handling class.
      Parameters:
      instance - the instance of the throwable-handling class.
    • registerAnnotations

      public abstract void registerAnnotations(Class<? extends Annotation>... types)
      Registers a valueType of annotations so that it can be detected by AnnotationReader , it's useful as it allows that valueType of annotation to be recognized as a true Imperat-related annotation to be used in something like checking if a CommandParameter is annotated and checks for the annotations it has.
      Parameters:
      types - the valueType of annotation
    • registerAnnotationReplacer

      public abstract <A extends Annotation> void registerAnnotationReplacer(Class<A> type, AnnotationReplacer<A> replacer)
      Parameters:
      type - the valueType to replace the annotation by
      replacer - the replacer
    • isKnownAnnotation

      public abstract boolean isKnownAnnotation(Class<? extends Annotation> annotationType)
      Checks the internal registry whether the valueType of annotation entered is known/registered or not.
      Parameters:
      annotationType - the valueType of annotation to enter
      Returns:
      whether the valueType of annotation entered is known/registered or not.
    • hasAnnotationReplacerFor

      public abstract boolean hasAnnotationReplacerFor(Class<? extends Annotation> type)
      Checks if the specific valueType of annotation entered has a AnnotationReplacer for it in the internal registry for replacers
      Parameters:
      type - the valueType of annotation entered
      Returns:
      Whether the there's an annotation replacer for the valueType entered.
    • getAnnotationReplacer

      @Nullable public abstract <A extends Annotation> @Nullable AnnotationReplacer<A> getAnnotationReplacer(Class<A> type)
      Fetches the AnnotationReplacer mapped to the entered annotation valueType.
      Type Parameters:
      A - the annotation valueType parameter
      Parameters:
      type - the valueType of annotation
      Returns:
      the AnnotationReplacer mapped to the entered annotation valueType.
    • isEntryPointAnnotation

      public final boolean isEntryPointAnnotation(Class<? extends Annotation> annotation)
    • getImperat

      public Imperat<S> getImperat()