The set of annotation processors that generate an accessor which returns an optional value for each annotated field during the compilation phase.
A set of annotation processors each of its generates getter methods that wrap a returned value by java.util.Optional
for fields without of any accessor. Designed for informational and/or testing purposes and are used mainly on DTOs.
is
prefix for boolean
types and get
one for any other types);ofNullable
method for nullable values and of
for non-null ones;Run a standalone sample project JAR (the bash script populates just a set of environment variables for convenience):
$ ./scripts/run <TYPE>
…where <TYPE>
is meant one of the processor types (e.g. $ ./scripts/run ast
).
There are a few implementations of the processors called processor types:
ast
- transform the AST using Lombok;byt
- modify bytecode at runtime using ASM;ref
- modify (refactor) source files using JavaParser.OG_JARPATH
- path to a jarfile that contains a Java agent (used by ASM).OG_SRCPATH
- source root directories separated by colons (used by JavaParser).There are too little information about how to create an annotation processor that modifies existing Java classes therefore I’ve published this repo. Hope it helps someone to be aware in the topic more faster than I made it.
Don’t forget to start the repo if it so :)
Code released under the MIT License in 2018 by Yurii Rabeshko.