A project needs to use the following combinaison of Jackson annotations together a lot. So, is there a way to create another annotation to avoid ugly copy/paste:
<
I would guess that you could write your own annotation classes
package org.codehaus.jackson.annotate ;
public @ interface JsonProperty
{
String value ( ) default "_id" ;
}
public @ interface JsonSerialize
{
Class using ( ) default IdSerializer.class ;
}
...
Compile these classes and make sure that are in your classpath before the original versions. This reduces but does not eliminate the copy/paste.
Then your code sample becomes
public class A {
@JsonProperty
@JsonSerialize
@JsonDeserialize
String id;
}
public class B {
@JsonProperty
@JsonSerialize
@JsonDeserialize
String id;
}
I realize it is not really what you wanted, but it is a start.