You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2020/08/25 07:42:00 UTC

[jira] [Commented] (CAMEL-15437) properties-binding: support binding from maps of maps

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

Claus Ibsen commented on CAMEL-15437:
-------------------------------------

I think at first we should add a new option to indicate that the properties is a map of maps (instead of some magic convention to try to guess).
But what can a good name for such option be.

So maybe just use

.map( ... here goes map of map )

Instead of .properties

> properties-binding: support binding from maps of maps
> -----------------------------------------------------
>
>                 Key: CAMEL-15437
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15437
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-core
>            Reporter: Luca Burgazzoli
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 3.5.0
>
>
> The properties binding component now support flat properties onlyso if oyu need to bind nesting object, you need to use an OGNL like syntax but it would be nice to support also "map of maps" as example to do the binding from as example JSON.
> Assuming we have a class like:
> {code:java}
> class Bar {
>     String name;
> }
> class Foo {
>     Bar bar;
> }
> {code}
> The it would be nice if we can bind from map like:
> {code:java}
> Map<Object, Object> properties = Map.of(
>     Map.of(
>         "bar",
>         Map.of("name", "test")
>     )
> );
> {code}
> Then one could use PropertyBindingSupport as usual:
> {code:java}
> Foo target = new Foo();
> PropertyBindingSupport.build()
>     .withCamelContext(context)
>     .withTarget(target)
>     .withProperties(properties)
>     .withRemoveParameters(false)
>     .bind();
> {code}
> The same copde using flat properties would look like:
> {code:java}
> Foo target = new Foo();
> PropertyBindingSupport.build()
>     .withCamelContext(context)
>     .withTarget(target)
>     .withProperties("bar.name", "test")
>     .withRemoveParameters(false)
>     .bind();
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)