There is a Spring approach to filter out fields from a service response with JSON views, but i am missing an equivalent approach to enrich a response with some dynamic/syntetic fields like this;
class User{
getFirstName(){...}
getLastName(){...}
getCreateDate(){...}
}
class UserViewA{
getFullName(){
return getLastName()+", "+getFirstName()
}
getCreateDate(){...}
}
class UserViewB{
getFullName(){
return getFirstName()+" "+getLastName()
}
getCreateDate(){...}
}
I could wrap the user within the view, but I do not want to propagate all needed user fields manually.
My other idea was to extend the views with the user object and create some sort of an reference linker to copy values references from the user object to the view, but this will get complicated with collections.
Is there some other approach or framework to achieve this? Is this concept not addressed in any way at all?
Update:
Clarification by example:
I am looking for a kind of facade solution/framework/approach.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With