Package host.anzo.commons.processors
Class ExtendedEnumProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
host.anzo.commons.processors.CommonProcessor
host.anzo.commons.processors.ExtendedEnumProcessor
- All Implemented Interfaces:
Processor
@AutoService(javax.annotation.processing.Processor.class)
@SupportedAnnotationTypes("host.anzo.commons.annotations.processors.ExtendedEnum")
public class ExtendedEnumProcessor
extends CommonProcessor
An annotation processor that enhances enums annotated with
@ExtendedEnum.
This processor automatically adds the following members to the annotated enum:
- A
private static final List<EnumType> cacheListfield, initialized withList.of(values()). - A
public static EnumType getValue(int ordinal)method to retrieve an enum constant by its ordinal using the cache. - A
public static List<EnumType> getValues()method that returns the cached list of enum constants.
values() method and provides convenient access methods.
It relies on the Javac AST manipulation utilities provided by CommonProcessor.- See Also:
-
Field Summary
Fields inherited from class host.anzo.commons.processors.CommonProcessor
maker, messager, names, treesFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) Processes annotations for a processing round.Methods inherited from class host.anzo.commons.processors.CommonProcessor
createQualifiedName, fieldExists, getSupportedSourceVersion, init, log, logError, logWarn, methodExistsMethods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, isInitialized
-
Constructor Details
-
ExtendedEnumProcessor
public ExtendedEnumProcessor()
-
-
Method Details
-
process
Processes annotations for a processing round.It finds all enums annotated with
@ExtendedEnum, verifies processor initialization, and then modifies the AST of each found enum to add the caching field and utility methods.- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor- Parameters:
annotations- The annotation types requested to be processed.roundEnv- Environment for information about the current and prior round.- Returns:
falsealways, as this processor does not claim the annotations. This allows other processors to potentially process the same annotations, though typically only one processor modifies a given element's structure.
-