felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Leangen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-5678) Allow merging of objects
Date Mon, 18 Sep 2017 06:11:00 GMT

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

David Leangen commented on FELIX-5678:

Hi [~bosschaert], thank you for your reply! I got sidetracked, but am finally turning my attention
back to this. :-)

bq. so you really want to convert two objects into one

That is a good question, and I suppose that it depends on the level of abstraction. From a
conceptual level, I think the intent is to update an object. For instance (just an example
I am pulling out of my ear), say I have a Customer object, and I notice that the last name
is spelled incorrectly. All I want to do is correct that part, so the system somehow receives
a message with the ID of the customer to update, and the portions of the records that need
to be updated. There is no point sending along the entire record if I only want to change
an "i" to an "e" in one single field!

However, from the converter/data level, I suppose you are right: it is really just merging
two objects. (Or is it?? Not sure yet.)

I was also starting to think that maybe a [diff format|http://wiki.c2.com/?DiffAlgorithm]
would work well. Each field, instead of containing an actual value, would contain only a diff

bq. While the converter API isn't really designed for this, you could achieve it with a custom
rule, where the rule is specifically created for this conversion with the second object as
context provided to the rule

Possible, yes. And IIUC the API is no longer open for comments, correct? So either we'd have
to go about it this way, or build an extra layer on top of the Converter. Or, maybe this is
something all together different.


> 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
> 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

View raw message