-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63432be
commit b014a57
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...neration/src/main/java/com/fluxtion/example/reference/CombineFunctionalAndImperative.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.fluxtion.example.reference; | ||
|
||
import com.fluxtion.compiler.Fluxtion; | ||
import com.fluxtion.compiler.builder.dataflow.DataFlow; | ||
import com.fluxtion.runtime.annotations.OnEventHandler; | ||
|
||
public class CombineFunctionalAndImperative { | ||
|
||
public static String toUpper(String incoming){ | ||
return incoming.toUpperCase(); | ||
} | ||
|
||
public static class MyNode { | ||
@OnEventHandler | ||
public boolean handleStringEvent(String stringToProcess) { | ||
System.out.println("IMPERATIVE received:" + stringToProcess); | ||
return true; | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
var processor = Fluxtion.interpret(cfg -> { | ||
DataFlow.subscribe(String.class) | ||
.console("FUNCTIONAL input: '{}'") | ||
.map(CombineFunctionalAndImperative::toUpper) | ||
.console("FUNCTIONAL transformed: '{}'"); | ||
|
||
cfg.addNode(new MyNode()); | ||
}); | ||
|
||
processor.init(); | ||
processor.onEvent("hello world"); | ||
} | ||
} |