diff --git a/teavm-classlib/pom.xml b/teavm-classlib/pom.xml
index 2b389ecb2..3697a4730 100644
--- a/teavm-classlib/pom.xml
+++ b/teavm-classlib/pom.xml
@@ -122,8 +122,9 @@
java.nio.charset
java.text
java.util
- java.util.logging
java.util.concurrent
+ java.util.function
+ java.util.logging
java.util.regex
java.util.zip
-output
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TFunctionalInterface.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TFunctionalInterface.java
new file mode 100644
index 000000000..8a64986e9
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TFunctionalInterface.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.lang;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface TFunctionalInterface {
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TComparator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TComparator.java
index fe591fde9..dac75c6a7 100644
--- a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TComparator.java
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/TComparator.java
@@ -15,11 +15,122 @@
*/
package org.teavm.classlib.java.util;
+import org.teavm.classlib.java.lang.TComparable;
+import org.teavm.classlib.java.util.function.TFunction;
+import org.teavm.classlib.java.util.function.TToDoubleFunction;
+import org.teavm.classlib.java.util.function.TToIntFunction;
+import org.teavm.classlib.java.util.function.TToLongFunction;
+
/**
*
* @author Alexey Andreev
* @param
*/
+@FunctionalInterface
public interface TComparator {
int compare(T o1, T o2);
+
+ default TComparator reversed() {
+ return (a, b) -> compare(b, a);
+ }
+
+ default TComparator thenComparing(TComparator super T> other) {
+ return (a, b) -> {
+ int r = compare(a, b);
+ if (r == 0) {
+ r = other.compare(a, b);
+ }
+ return r;
+ };
+ }
+
+ default TComparator thenComparing(TFunction super T, ? extends U> keyExtractor,
+ TComparator super U> keyComparator) {
+ return thenComparing(comparing(keyExtractor, keyComparator));
+ }
+
+ default > TComparator thenComparing(
+ TFunction super T,? extends U> keyExtractor) {
+ return (a, b) -> {
+ int r = compare(a, b);
+ if (r == 0) {
+ U k = keyExtractor.apply(a);
+ U m = keyExtractor.apply(b);
+ r = k != null ? k.compareTo(m) : -m.compareTo(k);
+ }
+ return r;
+ };
+ }
+
+ default TComparator thenComparingInt(TToIntFunction super T> keyExtractor) {
+ return (a, b) -> {
+ int r = compare(a, b);
+ if (r == 0) {
+ r = Integer.compare(keyExtractor.applyAsInt(a), keyExtractor.applyAsInt(b));
+ }
+ return r;
+ };
+ }
+
+ default TComparator thenComparingLong(TToLongFunction super T> keyExtractor) {
+ return (a, b) -> {
+ int r = compare(a, b);
+ if (r == 0) {
+ r = Long.compare(keyExtractor.applyAsLong(a), keyExtractor.applyAsLong(b));
+ }
+ return r;
+ };
+ }
+
+ default TComparator thenComparingDouble(TToDoubleFunction super T> keyExtractor) {
+ return (a, b) -> {
+ int r = compare(a, b);
+ if (r == 0) {
+ r = Double.compare(keyExtractor.applyAsDouble(a), keyExtractor.applyAsDouble(b));
+ }
+ return r;
+ };
+ }
+
+ static TComparator comparing(TFunction super T, ? extends U> keyExtractor,
+ TComparator super U> keyComparator) {
+ return (a, b) -> keyComparator.compare(keyExtractor.apply(a), keyExtractor.apply(b));
+ }
+
+ static > TComparator comparing(
+ TFunction super T, ? extends U> keyExtractor) {
+ return (a, b) -> {
+ U k = keyExtractor.apply(a);
+ U m = keyExtractor.apply(b);
+ return k != null ? k.compareTo(m) : -m.compareTo(k);
+ };
+ }
+
+ static > TComparator naturalOrder() {
+ return (o1, o2) -> o1 != null ? o1.compareTo(o2) : o2.compareTo(o1);
+ }
+
+ static > TComparator reverseOrder() {
+ return (o1, o2) -> o2 != null ? o2.compareTo(o1) : o1.compareTo(o2);
+ }
+
+ static TComparator nullsFirst(TComparator super T> comparator) {
+ return (a, b) -> a == null && b == null ? 0 : a == null ? -1 : b == null ? 1 : comparator.compare(a, b);
+ }
+
+ static TComparator nullsLast(TComparator super T> comparator) {
+ return (a, b) -> a == null && b == null ? 0 : a == null ? 1 : b == null ? -1 : comparator.compare(a, b);
+ }
+
+ static TComparator comparingInt(TToIntFunction super T> keyExtractor) {
+ return (a, b) -> Integer.compare(keyExtractor.applyAsInt(a), keyExtractor.applyAsInt(b));
+ }
+
+ static TComparator comparingLong(TToLongFunction super T> keyExtractor) {
+ return (a, b) -> Long.compare(keyExtractor.applyAsLong(a), keyExtractor.applyAsLong(b));
+ }
+
+ static TComparator comparingDouble(TToDoubleFunction super T> keyExtractor) {
+ return (a, b) -> Double.compare(keyExtractor.applyAsDouble(a), keyExtractor.applyAsDouble(b));
+ }
}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiConsumer.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiConsumer.java
new file mode 100644
index 000000000..af92ad87b
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiConsumer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TBiConsumer {
+ void accept(T t, U u);
+
+ default TBiConsumer andThen(TBiConsumer super T,? super U> after) {
+ return (t, u) -> {
+ this.accept(t, u);
+ after.accept(t, u);
+ };
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiFunction.java
new file mode 100644
index 000000000..8255a7d8a
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiFunction.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TBiFunction {
+ R apply(T t, U u);
+
+ default TBiFunction andThen(TFunction super R, ? extends V> after) {
+ return (t, u) -> after.apply(apply(t, u));
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiPredicate.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiPredicate.java
new file mode 100644
index 000000000..c4fb3d4c3
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBiPredicate.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+import java.util.function.BiPredicate;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TBiPredicate {
+ boolean test(T t, U u);
+
+ default TBiPredicate and(TBiPredicate super T, ? super U> other) {
+ return (t, u) -> test(t, u) && other.test(t, u);
+ }
+
+ default BiPredicate negate() {
+ return (t, u) -> !test(t, u);
+ }
+
+ default TBiPredicate or(TBiPredicate super T, ? super U> other) {
+ return (t, u) -> test(t, u) || other.test(t, u);
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBinaryOperator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBinaryOperator.java
new file mode 100644
index 000000000..e0e95f7cc
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBinaryOperator.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+import org.teavm.classlib.java.util.TComparator;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TBinaryOperator extends TBiFunction {
+ static TBinaryOperator minBy(TComparator super T> comparator) {
+ return (a, b) -> comparator.compare(a, b) <= 0 ? a : b;
+ }
+
+ static TBinaryOperator maxBy(TComparator super T> comparator) {
+ return (a, b) -> comparator.compare(a, b) >= 0 ? a : b;
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBooleanSupplier.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBooleanSupplier.java
new file mode 100644
index 000000000..7db80a9ed
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TBooleanSupplier.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TBooleanSupplier {
+ boolean getAsBoolean();
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TConsumer.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TConsumer.java
new file mode 100644
index 000000000..b4d5cd7c7
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TConsumer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TConsumer {
+ void accept(T t);
+
+ default TConsumer andThen(TConsumer super T> after) {
+ return t -> {
+ accept(t);
+ after.accept(t);
+ };
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleBinaryOperator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleBinaryOperator.java
new file mode 100644
index 000000000..b67df85d0
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleBinaryOperator.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleBinaryOperator {
+ double applyAsDouble(double left, double right);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleConsumer.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleConsumer.java
new file mode 100644
index 000000000..77182276d
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleConsumer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleConsumer {
+ void accept(double value);
+
+ default TDoubleConsumer andThen(TDoubleConsumer after) {
+ return e -> {
+ accept(e);
+ after.accept(e);
+ };
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleFunction.java
new file mode 100644
index 000000000..2f7da6143
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleFunction {
+ R apply(double value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoublePredicate.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoublePredicate.java
new file mode 100644
index 000000000..6174312cf
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoublePredicate.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoublePredicate {
+ boolean test(double value);
+
+ default TDoublePredicate and(TDoublePredicate other) {
+ return v -> test(v) && other.test(v);
+ }
+
+ default TDoublePredicate negate() {
+ return v -> !test(v);
+ }
+
+ default TDoublePredicate or(TDoublePredicate other) {
+ return v -> test(v) || other.test(v);
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleSupplier.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleSupplier.java
new file mode 100644
index 000000000..3e8aa8745
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleSupplier.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleSupplier {
+ double getAsDouble();
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleToIntFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleToIntFunction.java
new file mode 100644
index 000000000..64514973e
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleToIntFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleToIntFunction {
+ int applyAsInt(double value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleToLongFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleToLongFunction.java
new file mode 100644
index 000000000..af6c424ae
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleToLongFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleToLongFunction {
+ long applyAsLong(double value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleUnaryOperator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleUnaryOperator.java
new file mode 100644
index 000000000..b6be9eddf
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TDoubleUnaryOperator.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TDoubleUnaryOperator {
+ double applyAsDouble(double operand);
+
+ default TDoubleUnaryOperator compose(TDoubleUnaryOperator before) {
+ return v -> applyAsDouble(before.applyAsDouble(v));
+ }
+
+ default TDoubleUnaryOperator andThen(TDoubleUnaryOperator after) {
+ return v -> after.applyAsDouble(applyAsDouble(v));
+ }
+
+ static TDoubleUnaryOperator identity() {
+ return v -> v;
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TFunction.java
new file mode 100644
index 000000000..26236afe9
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TFunction.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TFunction {
+ R apply(T t);
+
+ default TFunction compose(TFunction super V, ? extends T> before) {
+ return v -> apply(before.apply(v));
+ }
+
+ default TFunction andThen(TFunction super R, ? extends V> after) {
+ return t -> after.apply(apply(t));
+ }
+
+ static TFunction identity() {
+ return t -> t;
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntBinaryOperator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntBinaryOperator.java
new file mode 100644
index 000000000..801e7e6aa
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntBinaryOperator.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntBinaryOperator {
+ int applyAsInt(int left, int right);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntConsumer.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntConsumer.java
new file mode 100644
index 000000000..3ebf78c21
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntConsumer.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntConsumer {
+ void accept(int value);
+
+ default TIntConsumer andThen(TIntConsumer after) {
+ return v -> {
+ accept(v);
+ after.accept(v);
+ };
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntFunction.java
new file mode 100644
index 000000000..1b9d62d03
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntFunction {
+ R apply(int value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntPredicate.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntPredicate.java
new file mode 100644
index 000000000..ab09e6fe4
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntPredicate.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntPredicate {
+ boolean test(int value);
+
+ default TIntPredicate and(TIntPredicate other) {
+ return v -> test(v) && other.test(v);
+ }
+
+ default TIntPredicate negate() {
+ return v -> !test(v);
+ }
+
+ default TIntPredicate or(TIntPredicate other) {
+ return v -> test(v) || other.test(v);
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntSupplier.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntSupplier.java
new file mode 100644
index 000000000..db77886a0
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntSupplier.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntSupplier {
+ int getAsInt();
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntToDoubleFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntToDoubleFunction.java
new file mode 100644
index 000000000..6e7d7eb7b
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntToDoubleFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntToDoubleFunction {
+ double applyAsDouble(int value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntToLongFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntToLongFunction.java
new file mode 100644
index 000000000..31d0f181f
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntToLongFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntToLongFunction {
+ long applyAsLong(int value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntUnaryOperator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntUnaryOperator.java
new file mode 100644
index 000000000..fd692371b
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TIntUnaryOperator.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TIntUnaryOperator {
+ int applyAsInt(int operand);
+
+ default TIntUnaryOperator compose(TIntUnaryOperator before) {
+ return v -> applyAsInt(before.applyAsInt(v));
+ }
+
+ default TIntUnaryOperator andThen(TIntUnaryOperator after) {
+ return v -> after.applyAsInt(applyAsInt(v));
+ }
+
+ static TIntUnaryOperator identity() {
+ return v -> v;
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TPredicate.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TPredicate.java
new file mode 100644
index 000000000..6a8284938
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TPredicate.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+import org.teavm.classlib.java.util.TObjects;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TPredicate {
+ boolean test(T t);
+
+ default TPredicate and(TPredicate super T> other) {
+ return t -> test(t) && other.test(t);
+ }
+
+ default TPredicate negate() {
+ return t -> !test(t);
+ }
+
+ default TPredicate or(TPredicate super T> other) {
+ return t -> test(t) || other.test(t);
+ }
+
+ default TPredicate isEqual(Object targetRef) {
+ return t -> TObjects.equals(t, targetRef);
+ }
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TSupplier.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TSupplier.java
new file mode 100644
index 000000000..8033863c9
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TSupplier.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TSupplier {
+ T get();
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToDoubleFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToDoubleFunction.java
new file mode 100644
index 000000000..a25548ede
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToDoubleFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TToDoubleFunction {
+ double applyAsDouble(T value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToIntFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToIntFunction.java
new file mode 100644
index 000000000..e97a65ead
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToIntFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TToIntFunction {
+ int applyAsInt(T value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToLongFunction.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToLongFunction.java
new file mode 100644
index 000000000..3f4ee8c57
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TToLongFunction.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TToLongFunction {
+ long applyAsLong(T value);
+}
diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TUnaryOperator.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TUnaryOperator.java
new file mode 100644
index 000000000..bf5fbcd56
--- /dev/null
+++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/util/function/TUnaryOperator.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2015 Alexey Andreev.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.teavm.classlib.java.util.function;
+
+/**
+ *
+ * @author Alexey Andreev
+ */
+@FunctionalInterface
+public interface TUnaryOperator extends TFunction {
+ static TUnaryOperator identity() {
+ return t -> t;
+ }
+}