Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grouping Multiple Annotations

I have java 1.7. Is there any way to group multiple annotations to single one. So that i annotate with single annotation and gets all the properties of all grouped multiple annotations. I want to avoid multiple annotation lines repeated every time. Can we use the 3 annotation into one Does java core libraries or others support this. Thnx

like image 215
Rahul Avatar asked Nov 13 '14 13:11

Rahul


People also ask

Can you apply more than one annotation on any method?

It is now possible to use an annotation zero times, once, or, if the annotation's type is marked as @Repeatable , more than once. It is also possible to restrict where an annotation type can be used by using the @Target meta-annotation.

Can you apply more than one annotation on any method in Java?

If you need to use multiple annotations in your test classes, you can use this technique to merge some annotations. In this way, whenever you need to add or change some annotation for your test classes, you can easy to modify it in your base annotation. In order to do this, you need to create a custom annotation class.

What are meta annotations in Java?

An annotation is a special type of interface in Java that can be used to describe Java constructs, such as classes, methods, and fields. According to the Java Language Specification (JLS): An annotation is a marker which associates information with a program construct, but has no effect at run time.


1 Answers

I'm not sure if this is what you're looking for, but CDI provide stereotype annotations.

like image 57
Puce Avatar answered Oct 03 '22 06:10

Puce