In my code, I'm going to have lots of getters like this with the same set of annotations (one for Hibernate and others for Jackson):
@Transient
@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = BaseEntity.JSON_DATETIME_FORMAT)
public LocalDateTime getCreatedDateDT() {
return DateTimeUtils.klabTimestampToLocalDateTime(getCreatedDate(), createdDateDT);
}
I want to minimize repetion by implementing my own annotation, which will mean all these four together, like this:
@TransientLocalDateTime
public LocalDateTime getCreatedDateDT() {
return DateTimeUtils.klabTimestampToLocalDateTime(getCreatedDate(), createdDateDT);
}
How can I do it? Is this even possible?
UPDATE Thanks to Konstantin Yovkov, now I know, that I can combine all Jackson annotations in one, but that is because Jackson's annotation processor recognizes such a trick. I wonder if it is possible to make any annotation processor do that? It seems to me that it's not.