Reputation: 7021
I want to find a proper manner to build different json according to different context;
for example, given
@Data
public class Individual {
private Address address;
@myAnnotation(Perso.class)
private String firstName;
@myAnnotation(Perso.class)
private String lastName;
@myAnnotation(Finance.class)
private String bankName;
}
@Data
public class Address {
@myAnnotation(Perso.class)
private String street;
@myAnnotation(Perso.class)
private String number;
}
I want to have a certain annotation that filters the properties for me smartly
for example, if I run my serializer in the context of "Perso" it gives me
{
address : {
street: "XXXX"
number: "XXXX"
}
firstName: "XXXX"
lastName: "XXXX"
}
but if I run it in the context of "Finance" it gives me only
{
bankName: "XXXX"
}
I know that javax validation is using the same thins with annotations where it declares groups: for example @NotBlank(groups = {PersonalDataForm.class})
I want to have a light functionality that allows me to do the same!
Is there any library that allows me to do what I am aiming to do?
Upvotes: 0
Views: 55