jackson rest service - returning URI instead of child “objects”
posted 1 year ago
I have a rather complex problem that I cannot find a good solution for. I have a tree like object structure with a:
Node being extended by
possible future nodes
Node has several methods like:
getChildren() - returning a List of Node
This schema works if I want to get the whole tree as json. However, when I want to get a single Node like ConditionNode, my goal is to return a list of URIs pointing to the children nodes instead of returning all the children that one node might have:
So my idea was to have a third class UrlNodewhich also extends Node, but that results in having more properties in UrlNodethan I need (like uuid, treeName, ...).
So I have three goals.
I want my children to be composable, so everything can be a child and therefor has to be a Node.
I want to have a class that only contains the URI and return that single class as a child representation for single ChildNodes.
I want everything to be able to be reverse mapped. So not only have rest services return json, but also being able to map the returned json into the same objects again (mainly for testing).