Skip to content

Commit ae15dd5

Browse files
committed
More documentation
- Add future example - Remove hard coded `javaHome` path and document how to set up SBT to use Java 8.
1 parent f786fef commit ae15dd5

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,27 @@ A set of [Functional Interfaces](http://download.java.net/jdk8/docs/api/java/lan
44
for `scala.FunctionN`. These are designed for convenient construction of Scala functions
55
using Java 8 lambda syntax.
66

7+
### Usage
8+
9+
```java
10+
import scala.concurrent.*;
11+
import static scala.runtime.F.func;
12+
13+
class Test {
14+
private static Future<Integer> futureExample(Future<String> future, ExecutionContext ec) {
15+
return future.map(func(s -> s.toUpperCase()), ec).map(func(s -> s.length()), ec);
16+
}
17+
}
18+
```
19+
20+
[More Examples / Documentation](https://github.com/retronym/java-8-function1/blob/master/src/test/java/scala/runtime/test/Test.java)
21+
22+
### Hacking
23+
24+
[Code Generator](https://github.com/retronym/java-8-function1/blob/master/project/CodeGen.scala)
25+
26+
#### Running Examples
27+
28+
```
29+
% (export JAVA_HOME=`java_home 1.8`; export PATH=$JAVA_HOME/bin:$PATH; sbt 'test:runMain scala.runtime.test.Test')
30+
```

build.sbt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
scalaVersion := "2.11.0-RC1"
22

3-
javaHome := Some(file("/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home"))
4-
53
sourceGenerators in Compile <+= sourceManaged in Compile map { dir =>
64
def write(name: String, content: String) = {
75
val f = dir / "scala" / "runtime" / s"${name}.java"

src/test/java/scala/runtime/test/Test.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public static void main(String[] args) {
9393
acceptFunction22Unit( proc((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22) -> {v1.toUpperCase(); return;}));
9494
}
9595

96+
private static scala.concurrent.Future<Integer> futureExample(
97+
scala.concurrent.Future<String> future, scala.concurrent.ExecutionContext ec) {
98+
return future.map(func(s -> s.toUpperCase()), ec).map(func(s -> s.length()), ec);
99+
}
100+
96101
private static void sideEffect() {
97102
}
98103

0 commit comments

Comments
 (0)