类 ErrorCodeProcessor

java.lang.Object
javax.annotation.processing.AbstractProcessor
io.github.tcq1007.valid.errorcode.ErrorCodeProcessor
所有已实现的接口:
Processor

@AutoService(javax.annotation.processing.Processor.class) @SupportedAnnotationTypes("io.github.tcq1007.valid.errorcode.ValidErrorCode") @SupportedSourceVersion(RELEASE_21) public class ErrorCodeProcessor extends AbstractProcessor
Annotation processor for validating error codes in enum classes.

This processor validates error codes defined in enum classes according to specified rules including:

  • Format validation (prefix, length)
  • Uniqueness across the codebase
  • Type correctness

The processor is automatically registered for processing through the AutoService annotation and processes all enum classes annotated with ValidErrorCode.

Example usage:


 @ValidErrorCode(prefix = "E", length = 5)
 public enum ErrorCodes {
     E10001("System error"),
     E10002("Invalid input");
     // ...
 }
 

另请参阅:
  • 构造器详细资料

    • ErrorCodeProcessor

      public ErrorCodeProcessor()
      Constructs a new ErrorCodeProcessor.

      This constructor is required by the annotation processing API and will be called by the Java compiler when initializing the processor.

  • 方法详细资料

    • init

      public void init(ProcessingEnvironment processingEnv)
      Initializes the processor with the processing environment.

      This method is called by the Java compiler to initialize the processor with the processing environment. It sets up the required utilities for error reporting, element handling, and AST operations.

      指定者:
      init 在接口中 Processor
      覆盖:
      init 在类中 AbstractProcessor
      参数:
      processingEnv - The processing environment provided by the compiler, containing utilities for the annotation processor.
    • process

      public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv)
      Processes the annotations found in the source files.
      指定者:
      process 在接口中 Processor
      指定者:
      process 在类中 AbstractProcessor
      参数:
      annotations - The set of annotations to process.
      roundEnv - The current round environment.
      返回:
      True if the annotations were processed, false otherwise.