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
Showing
14 changed files
with
1,219 additions
and
149 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
60 changes: 60 additions & 0 deletions
60
akka-samples/akka-docs-java-lambda/src/test/java/docs/stream/SilenceSystemOut.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,60 @@ | ||
package docs.stream; | ||
|
||
import akka.actor.ActorRef; | ||
|
||
import java.util.function.Predicate; | ||
|
||
/** | ||
* Acts as if `System.out.println()` yet swallows all messages. Useful for putting printlines in examples yet without poluting the build with them. | ||
*/ | ||
public class SilenceSystemOut { | ||
|
||
private SilenceSystemOut() { | ||
} | ||
|
||
public static System get() { | ||
return new System(new System.Println() { | ||
@Override | ||
public void println(String s) { | ||
// ignore | ||
} | ||
}); | ||
} | ||
|
||
public static System get(ActorRef probe) { | ||
return new System(new System.Println() { | ||
@Override | ||
public void println(String s) { | ||
probe.tell(s, ActorRef.noSender()); | ||
} | ||
}); | ||
} | ||
|
||
public static System get(Predicate<String> filter, ActorRef probe) { | ||
return new System(new System.Println() { | ||
@Override | ||
public void println(String s) { | ||
if (filter.test(s)) | ||
probe.tell(s, ActorRef.noSender()); | ||
} | ||
}); | ||
} | ||
|
||
public static class System { | ||
public final Println out; | ||
|
||
public System(Println out) { | ||
this.out = out; | ||
} | ||
|
||
public static abstract class Println { | ||
public abstract void println(String s); | ||
|
||
public void println(Object s) { | ||
println(s.toString()); | ||
} | ||
} | ||
|
||
} | ||
|
||
} |
Oops, something went wrong.