Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jackson rest service - returning URI instead of child “objects”  RSS feed

Sven Richter
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • ConditionNode
  • ResultNode
  • possible future nodes

  • Node has several methods like:
  • getChildren() - returning a List of Node
  • getTreeName()
  • getUuid()

  • 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).

  • Is there a common design pattern for this?


    PS: I also asked this on SO: SO-Link if someone wants to earn some points.
    It is sorta covered in the JavaRanch Style Guide.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!