Luca Burgazzoli created CAMEL-13631:
---------------------------------------
Summary: 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
Fix For: 3.0.0.M4
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)