I have a couple of json properties which should be handled by multiple aanotations
From design's best practices, should I have multiple repeating annotations (from a standard library) or should I create a customized annotation to handle them together?
for example which version is beeter:
public class A{
private static final String DATE_PATTERN = "yyyy-MM-dd";
@JsonProperty
private String name;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_PATTERN)
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate date1;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_PATTERN)
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate date2;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_PATTERN)
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate rdate3;
}
public class B{
@JsonProperty
private String name;
@customeDateFormatter
private LocalDate date1;
@customeDateFormatter
private LocalDate date2;
@customeDateFormatter
private LocalDate rdate3;
}
where @customeDateFormatter
defined in another class