[ 
https://issues.apache.org/jira/browse/FELIX-5678?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16852604#comment-16852604
 ] 

David Leangen commented on FELIX-5678:
--------------------------------------

Just to update the information here with two discoveries as I continue to 
investigate...

Although perhaps frequently required, the number of "places" in the code where 
the patch operation is required is probably limited, mostly to the lower-level 
data layer. This would be an argument against having a patch operation in the 
Converter.

An argument for, though, is that a patch may be "deep". This turns out to be 
non-trivial (i.e. more complex than just putAll as you suggest), as there is a 
need to iterate deep into the object. This traversal is already being done 
internally by the Converter, so it may provide a great opportunity to perform 
this operation from inside the Converter.

> Allow merging of objects
> ------------------------
>
>                 Key: FELIX-5678
>                 URL: https://issues.apache.org/jira/browse/FELIX-5678
>             Project: Felix
>          Issue Type: Bug
>          Components: Converter
>            Reporter: David Leangen
>            Priority: Major
>
> Given a typed object O1 and a "partial" representation of an object O2 (for 
> instance in the form of a Map), allow O2 to be merged into O1.
> Example:
> {code}
> public class Foo {
>   public String a;
>   public String b;
>   public String c;
> }
> Foo f = new Foo();
> a = "Eh!";
> b = "Be cool.";
> c = "See you later?";
> Map<String, String> m = new Map<>();
> m.put("b", "Be there or be square");
> Foo f2 = Converter.convert(f).merge(m);
> {code}
> I am sure there are many ways to skin this cat.
> If the Converter API cannot be changed, what would be the best way to tackle 
> this problem?
> (In the meantime, while awaiting comments form [~bosschaert], I'll try to run 
> a few experiments to see if I can come up with something reasonable.)



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to