In my current project I have this group of big and complicated annotations I have to put on a lots of fields around my class. They are Jackson json annotations.
@JsonSerialize(using = IViewableToReferenceSerializer.class, contentUsing = IViewableToReferenceSerializer.class)
private ComplexeObject myObject;
and I would like to substitute it to something like:
@JsonAsReference
private ComplexeObject myObject;
I already tested the system without the custom annotation and it works fine. I though I could define my annotation as (for example):
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@JsonSerialize(using = IViewableToReferenceSerializer.class, contentUsing = IViewableToReferenceSerializer.class)
public @interface JsonAsReference {
}
So my question is: Is it even possible? Or am I just doing something wrong?
UPDATE: I found an answer for the particuliar Jackson case in this thread Create a custom Jackson annotation
but I am open to any general case solution.