You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by jdeane <je...@gmail.com> on 2015/09/11 16:56:48 UTC
Processor Interface and Java Lambda Expression
In Java 8+ I can replace
process(new Processor() {
public void process(Exchange exchange) {
String uuid = UUID.randomUUID().toString();
exchange.getIn().setHeader("CareManagementID", uuid);
}
}).
with
process((exchange) -> {
String uuid = UUID.randomUUID().toString();
exchange.getIn().setHeader("CareManagementID", uuid);
}).
using a Java Lambda expression. This is because the Processor Interface
adherers to Java 8+ definition of a Functional Interface (minus the optional
Annotation).
Does anyone have objections to this approach or believe that the Processor
Interface would ever change in the future?
--
View this message in context: http://camel.465427.n5.nabble.com/Processor-Interface-and-Java-Lambda-Expression-tp5771449.html
Sent from the Camel Development mailing list archive at Nabble.com.
Re: Processor Interface and Java Lambda Expression
Posted by Claus Ibsen <cl...@gmail.com>.
Yeah sure this is fine.
The processor interface will not change, it has been the same for 8 years now.
On Fri, Sep 11, 2015 at 4:56 PM, jdeane <je...@gmail.com> wrote:
> In Java 8+ I can replace
>
> process(new Processor() {
> public void process(Exchange exchange) {
> String uuid = UUID.randomUUID().toString();
> exchange.getIn().setHeader("CareManagementID", uuid);
> }
> }).
>
> with
>
> process((exchange) -> {
> String uuid = UUID.randomUUID().toString();
> exchange.getIn().setHeader("CareManagementID", uuid);
> }).
>
> using a Java Lambda expression. This is because the Processor Interface
> adherers to Java 8+ definition of a Functional Interface (minus the optional
> Annotation).
>
> Does anyone have objections to this approach or believe that the Processor
> Interface would ever change in the future?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Processor-Interface-and-Java-Lambda-Expression-tp5771449.html
> Sent from the Camel Development mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2nd edition:
https://www.manning.com/books/camel-in-action-second-edition