Annotation Processor Annotation processors can be used to generate the classes at compile time basis on specified annotations. So we can define annotations, we can use them on classes and then we can process them using annotation processor. Here we will see how we can use Annotation processor in Java to generate the classes at runtime. We will try to generate the DTO (Data transfer object) classes from entity classes. There are situation when a developer has to write DTO classes for the Entity class with almost same fields, so data can be transferred from one layer to another layer like UI to backend and backend to UI. We can use entity objects also to transfer between UI and backed but it will create more problem instead of solving as entity objects live in transaction context and reading or updating them in non-transactional context may change their state which may not be as expected. I just took the example of UI and backend but there can be many other scenario when it is requir...
Blogs about Java, J2ee, Multithreading, Data structure, Algorithm, Spring framework, Spring boot, Web services and open source technologies