You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2019/06/11 10:10:00 UTC

[jira] [Work logged] (CAMEL-13631) PropertyBindingSupport to support key filtering and transformation

     [ https://issues.apache.org/jira/browse/CAMEL-13631?focusedWorklogId=257577&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-257577 ]

ASF GitHub Bot logged work on CAMEL-13631:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Jun/19 10:09
            Start Date: 11/Jun/19 10:09
    Worklog Time Spent: 10m 
      Work Description: lburgazzoli commented on pull request #2970: CAMEL-13631: PropertyBindingSupport to support key filtering and transformation
URL: https://github.com/apache/camel/pull/2970
 
 
   
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 257577)
            Time Spent: 10m
    Remaining Estimate: 0h

> PropertyBindingSupport to support key filtering and transformation
> ------------------------------------------------------------------
>
>                 Key: CAMEL-13631
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13631
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-core
>            Reporter: Luca Burgazzoli
>            Assignee: Luca Burgazzoli
>            Priority: Minor
>             Fix For: 3.0.0.M4
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> It is common that you want to filter out or transform properties before they are applied to a target, for example you may want to filter out by prefix and in camel-k we do something like that:
> {code}
> public static int bindProperties(CamelContext context, Properties properties, Object target, String prefix) {
>         final AtomicInteger count = new AtomicInteger();
>         properties.entrySet().stream()
>             .filter(entry -> entry.getKey() instanceof String)
>             .filter(entry -> entry.getValue() != null)
>             .filter(entry -> ((String)entry.getKey()).startsWith(prefix))
>             .forEach(entry -> {
>                     final String key = ((String)entry.getKey()).substring(prefix.length());
>                     final Object val = entry.getValue();
>                     try {
>                         if (PropertyBindingSupport.bindProperty(context, target, key, val)) {
>                             count.incrementAndGet();
>                         }
>                     } catch (Exception ex) {
>                         throw new RuntimeException(ex);
>                     }
>                 }
>             );
>         return count.get();
>     }
> {code}
> Would be nice to have a support for filtering out of the box



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