I found a similar question and answer -> How can I validate two or more fields in combination?
But I want to make it reusable way without using inheritance.
For example, I want to write an annotation that checks that end date must be greater than start date.
class A {
Date startDate;
Date endDate;
}
class B {
Date startDate;
Date endDate;
}
According to the answer I linked, I need to write 2 separate annotations. How can I do it with single annotation?