类 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");
// ...
}
- 另请参阅:
-
字段概要
从类继承的字段 javax.annotation.processing.AbstractProcessor
processingEnv -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明voidinit(ProcessingEnvironment processingEnv) Initializes the processor with the processing environment.booleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) Processes the annotations found in the source files.从类继承的方法 javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, getSupportedSourceVersion, isInitialized
-
构造器详细资料
-
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
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
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.
-