Skip to content

[JBMAR-192] Proper by-reference cloning #223

@dmlloyd

Description

@dmlloyd

@dmlloyd opened JBMAR-192 and commented

Implement a cloner configuration option to pass by reference whenever possible.

The general behavioral contract would be to only clone an object when its type class is not equal to the cloned type class for that object, or if any of its contents (fields or array members) fail this test.

Because object graphs may be circular, a simple recursive determination cannot be used because the decision to clone an object cannot be made until all of its contents are evaluated. Thus the decision for each object in the graph has to be deferred until all objects have been visited, meaning that cloning must occur in two passes: the first pass to map the object graph and make simple clone/no clone determinations, and the second pass to make the final determination and instantiate and populate the object graph.

There is a more optimal recursive solution for non-cyclic object graphs which is similar to the existing algorithm. It would be possible to use a configuration option to establish that the optimal algorithm is preferred (which consequently will cause cyclic object graphs to fail).


No further details from JBMAR-192

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions