Today, the cyclic reference management with ExclusionStrategy is based on Type
and Field properties, but sometime it would be nice to exclude some properties
based on a particular serialization context.
The goal would be to allow to write a "CycleDetectionStrategy" or something
like that would behave like the json-lib
(.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT)). Basically, this
tells the json serializer to ignore any cyclic reference. While this might look
scary and dangerous, it is often just what is needed and avoid much boiler
plate code, and even take care of scenarios where the ExclusionStrategy would
not work.
For example, let's say that we have a "Project" java object, that have a
"getTasks()" and each Task has the "getProject()"
If I want to serialize, a Project and send it to the wire, I would just need
the Project info, and the .tasks of all the task, but I would not want to
re-serialize the project for each individual Task obviously.
Now, sometime, I might just want to serialize a particular task, and in this
case, I might want to get the Project back.
And even to go further, when I serialize a single task, I might want the Task,
and the .project properties, but without the .project.tasks. I then that this
last case should be handle with the ExclusionStrategy, but it would be nice to
have a smooth API to handle this case, with the east amount of Type specific
coding.
Note: This is an "enhancement" not an issue, but I was not sure how to set this
up.
Original issue reported on code.google.com by jeremy.c...@gmail.com on 28 Oct 2013 at 5:58
Original issue reported on code.google.com by
jeremy.c...@gmail.com
on 28 Oct 2013 at 5:58