I want to create a java annotation which generates a method in compile-time, like Lombok for example: I have this class :
@MyNewAnnotation() public class ClassTest { private String name; private Integer id; private String lastName; public final static String COL_NAME = "NAME"; public final static String COL_LAST_NAME = "LAST_NAME"; } I want that's myNewAnnotation can generate the getCol-method which returns "NAME, LAST_NAME" for example:
public static String getCol() { return COL_NAME + "," + COL_LAST_NAME; } The annotation has to read all attributes which start with "COL_" and with them generate the new method in compile-time, more or less like Lombok when generating getters or setters
@Getterdoesn't generate the method until you compile/build your project. Please check this out. It describes how to implement that exactly. For code generation, there are several libraries you can use.