Jackson 관련 어노테이션을 여러개 묶어 쓰려면 @JacksonAnnotationsInside 이 필수
서론
JacksonAnnotation을 많은 클래스에 붙여야 할 때가 있다. 근데 우선 하나가 아니라 굉장히 번잡해보이고, 변경할 때 다같이 바꿔줘야하니 힘들고, 무엇보다 나열된 어노테이션만 봤을때 이게 왜 쓰여야하는 어노테이션인지 한번에 알기 힘들다.
처음에는 class에만 붙이면, nested class 에 자동 적용되는 그런 것이 있을까 검색해보다 없는거같아 포기하고, Custom annotation을 만들어서 해보려 했는데, 적용이 안되더라. 자바 알못이라 커스텀 어노테이션에 어노테이션 여러개 붙여두면 알아서 unwrap 될 줄 알고 그랬다. (이때까지 쓰던 annotation들이 unwrap을 해주던거지, 이건 아니더라.)
그래서 찾아보니 @JacksonAnnotationsInside
라는 어노테이션이 이 역할을 해주더라
본론
(Jackson Annotation wiki)[https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations#meta-annotations]
이 어노테이션에 대한 정보는 위키에 있다. 처음부터 위키 정독했으면 안 헷갈렸겠다. 위키에서도 딱 내가 원하는 용도에 쓸 수 있다고 하고 있다.
used to allow "annotation bundles", custom annotations that are annotated with Jackson annotations (why? to allow adding just a single annotation to represent set of multiple Jackson annotations)
아주 좋다.
결론
Jackson annotation을 custom annoation으로 묶어 쓸때는 @JacksonAnnotationsInside
을 붙여줘야 Jackson에서 잘 처리해준다.
끝