How to create an annotation that is a group of Jackson annotations?
For Jackson, this can be done with @JacksonAnnotationsInside
meta-annotation. See this article for more, but code snippet from there is:
@Retention(RetentionPolicy.RUNTIME) // IMPORTANT
@JacksonAnnotationsInside
@JsonInclude(Include.NON_NULL)
@JsonPropertyOrder({ "id", "name" })
public @interface MyStdAnnotations
and from thereon you can use this type for your own classes like so:
@MyStdAnnotations
public class MyBean {
public String name, id;
}
There are some examples here on how to make various combinations of annotations containing other annotations. Is this what you're looking for?
Example from the source:
@Target(ElementType.METHOD)
public @interface SimpleAnnotation {
public String a();
public int b();
)
@Target(ElementType.METHOD)
public @interface ReallyComplexAnnotation {
public SimpleAnnotation[] value();
)
Used like this:
@ReallyComplexAnnotation(
{ @SimpleAnnotation(a="...", b=3), @SimpleAnnotation(a="...", b=4) }
)