8000 Add remaining java.util.function interfaces · renowncoder/scala-js@cfb4888 · GitHub
[go: up one dir, main page]

Skip to content

Commit cfb4888

Browse files
committed
Add remaining java.util.function interfaces
Fix scala-js#4227, fix scala-js#4228, and fix scala-js#4229
1 parent b859721 commit cfb4888

File tree

54 files changed

+1448
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1448
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait DoubleBinaryOperator {
17+
def applyAsDouble(left: Double, right: Double): Double
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
import scala.scalajs.js.annotation.JavaDefaultMethod
16+
17+
@FunctionalInterface
18+
trait DoubleConsumer {
19+
def accept(value: Double): Unit
20+
21+
@JavaDefaultMethod
22+
def andThen(after: DoubleConsumer): DoubleConsumer = { (value: Double) =>
23+
this.accept(value)
24+
after.accept(value)
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait DoubleFunction[R] {
17+
def apply(value: Double): R
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait DoubleToIntFunction {
17+
def applyAsInt(value: Double): Int
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait DoubleToLongFunction {
17+
def applyAsLong(value: Double): Long
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
import scala.scalajs.js.annotation.JavaDefaultMethod
16+
17+
@FunctionalInterface
18+
trait DoubleUnaryOperator {
19+
def applyAsDouble(operand: Double): Double
20+
21+
@JavaDefaultMethod
22+
def andThen(after: DoubleUnaryOperator): DoubleUnaryOperator = { (d: Double) =>
23+
after.applyAsDouble(applyAsDouble(d))
24+
}
25+
26+
@JavaDefaultMethod
27+
def compose(before: DoubleUnaryOperator): DoubleUnaryOperator = { (d: Double) =>
28+
applyAsDouble(before.applyAsDouble(d))
29+
}
30+
}
31+
32+
object DoubleUnaryOperator {
33+
def identity(): DoubleUnaryOperator = (d: Double) => d
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed un 93C6 der Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait IntBinaryOperator {
17+
def applyAsInt(left: Int, right: Int): Int
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
import scala.scalajs.js.annotation.JavaDefaultMethod
16+
17+
@FunctionalInterface
18+
trait IntConsumer {
19+
def accept(value: Int): Unit
20+
21+
@JavaDefaultMethod
22+
def andThen(after: IntConsumer): IntConsumer = { (value: Int) =>
23+
this.accept(value)
24+
after.accept(value)
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait IntFunction[R] {
17+
def apply(value: Int): R
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait IntToDoubleFunction {
17+
def applyAsDouble(value: Int): Double
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait IntToLongFunction {
17+
def applyAsLong(value: Int): Long
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
import scala.scalajs.js.annotation.JavaDefaultMethod
16+
17+
@FunctionalInterface
18+
trait IntUnaryOperator {
19+
def applyAsInt(operand: Int): Int
20+
21+
@JavaDefaultMethod
22+
def andThen(after: IntUnaryOperator): IntUnaryOperator = { (i: Int) =>
23+
after.applyAsInt(applyAsInt(i))
24+
}
25+
26+
@JavaDefaultMethod
27+
def compose(before: IntUnaryOperator): IntUnaryOperator = { (i: Int) =>
28+
applyAsInt(before.applyAsInt(i))
29+
}
30+
}
31+
32+
object IntUnaryOperator {
33+
def identity(): IntUnaryOperator = (i: Int) => i
34+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait LongBinaryOperator {
17+
def applyAsLong(left: Long, right: Long): Long
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
import scala.scalajs.js.annotation.JavaDefaultMethod
16+
17+
@FunctionalInterface
18+
trait LongConsumer {
19+
def accept(value: Long): Unit
20+
21+
@JavaDefaultMethod
22+
def andThen(after: LongConsumer): LongConsumer = { (value: Long) =>
23+
this.accept(value)
24+
after.accept(value)
25+
}
26+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait LongFunction[R] {
17+
def apply(value: Long): R
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait LongToDoubleFunction {
17+
def applyAsDouble(value: Long): Double
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Scala.js (https://www.scala-js.org/)
3+
*
4+
* Copyright EPFL.
5+
*
6+
* Licensed under Apache License 2.0
7+
* (https://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package java.util.function
14+
15+
@FunctionalInterface
16+
trait LongToIntFunction {
17+
def applyAsInt(value: Long): Int
18+
}

0 commit comments

Comments
 (0)
0