public class AggregationStrategyClause<T> extends Object implements AggregationStrategy
Constructor and Description |
---|
AggregationStrategyClause(T parent) |
Modifier and Type | Method and Description |
---|---|
Exchange |
aggregate(Exchange oldExchange,
Exchange newExchange)
Aggregates an old and new exchange together to create a single combined exchange
|
T |
body(BiFunction<Object,Object,Object> function)
Define an aggregation strategy which targets Exchanges In Body.
|
<B> T |
body(Class<B> type,
BiFunction<B,B,Object> function)
Define an aggregation strategy which targets Exchanges In Body.
|
<O,N> T |
body(Class<O> oldType,
Class<N> newType,
BiFunction<O,N,Object> function)
Define an aggregation strategy which targets Exchanges In Body.
|
T |
exchange(BiFunction<Exchange,Exchange,Exchange> function)
Define an aggregation strategy which targets the exchnage.
|
T |
message(BiFunction<Message,Message,Message> function)
Define an aggregation strategy which targets Exchanges In Message.
|
public AggregationStrategyClause(T parent)
public Exchange aggregate(Exchange oldExchange, Exchange newExchange)
AggregationStrategy
aggregate
in interface AggregationStrategy
oldExchange
- the oldest exchange (is null on first aggregation as we only have the new exchange)newExchange
- the newest exchange (can be null if there was no data possible to acquire)public T exchange(BiFunction<Exchange,Exchange,Exchange> function)
public T message(BiFunction<Message,Message,Message> function)
from("direct:aggregate") .aggregate() .message((old, new) -> { if (old == null) { return new; } String oldBody = old.getBody(String.class); String newBody = new.getBody(String.class); old.setBody(oldBody + "+" + newBody); return old; });
public T body(BiFunction<Object,Object,Object> function)
from("direct:aggregate") .aggregate() .body((old, new) -> { if (old == null) { return new; } return old.toString() + new.toString(); });
public <B> T body(Class<B> type, BiFunction<B,B,Object> function)
from("direct:aggregate") .aggregate() .body(String.class, (old, new) -> { if (old == null) { return new; } return old + new; });
Apache Camel