Annotation replacers
This page explains how to use the AnnotationReplacer interface to dynamically replace custom annotations.
Overview
Interface Definition
@FunctionalInterface
public interface AnnotationReplacer<T extends Annotation> {
/**
* Returns a collection of annotations that will substitute the given annotation,
* and be accessible in {@link AnnotationList#get(Class)}.
*
* @param element The element (method, parameter, class, etc.)
* @param annotation The annotation to replace.
* @return The list of replacing annotations. The collection may be null or empty.
*/
@Nullable Collection<Annotation> replaceAnnotation(@NotNull AnnotatedElement element, @NotNull T annotation);
}How It Works
Example: Creating and Using @PluginCommand
@PluginCommandStep 1: Define the @PluginCommand Annotation
@PluginCommand AnnotationStep 2: Implement the AnnotationReplacer for @PluginCommand
AnnotationReplacer for @PluginCommandStep 3: Register the Replacer
Step 4: Using the @PluginCommand Annotation
@PluginCommand AnnotationSummary
Last updated
Was this helpful?