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

David Bosschaert commented on FELIX-5678:
-----------------------------------------

Hi [~dleangen],

I think the simplest solution would be to take your 2 objects and convert them 
both to simple Maps using the converter. Then you can merge the 2 maps by 
calling {{map1.putAll(map2)}}
 Finally you can convert your resulting map back to the target object you need 
using the converter.

Alternatively you should be able to use a custom converter rule like described 
in the first comment, and in more detail here: 
[https://osgi.org/specification/osgi.enterprise/7.0.0/util.converter.html#util.converter-customizing.converters]

Let me know if this helps...

Cheers,

David

> 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