I’m relatively new to Java EE development and although I understand what annotations are, and how to use them, I am having difficulty “seeing the forest through the trees” when it comes to understanding why anyone would need to write and process their own annotations.
Under what circumstances would you even need a custom annotation?
I’m sure they are crucial somehow, I’m just don’t see their usefulness for some reason.
Thanks for any nudges in the right direction!
There are a lot of usages for custom annotations. You might think that it’s hard to find the reason why we would create one because many have been defined in other framework. In order to basically answer your own question, you should ask “What happened if those frameworks didn’t exist, would I need to create my custom use of annotations?” The likely answer would be yes. The following are some of few examples:
To answer your question, everytime you want to enrich your class through additional metadata that hasn’t been covered by other framework, you might be thinking of creating your own annotations. While, a lot of smart people cover the common usages for annotations, that doesn’t hinder you for coming up with your own usage in the future and thus the need for your own custom annotation and processing.