< prev index next >
test/jdk/tools/jpackage/helpers/jdk/jpackage/test/Functional.java
Print this page
*** 21,34 ****
* questions.
*/
package jdk.jpackage.test;
import java.lang.reflect.InvocationTargetException;
! import java.util.function.Consumer;
! import java.util.function.Function;
! import java.util.function.Predicate;
! import java.util.function.Supplier;
public class Functional {
@FunctionalInterface
public interface ThrowingConsumer<T> {
--- 21,31 ----
* questions.
*/
package jdk.jpackage.test;
import java.lang.reflect.InvocationTargetException;
! import java.util.function.*;
public class Functional {
@FunctionalInterface
public interface ThrowingConsumer<T> {
*** 44,53 ****
--- 41,65 ----
};
}
}
@FunctionalInterface
+ public interface ThrowingBiConsumer<T, U> {
+ void accept(T t, U u) throws Throwable;
+
+ public static <T, U> BiConsumer<T, U> toBiConsumer(ThrowingBiConsumer<T, U> v) {
+ return (t, u) -> {
+ try {
+ v.accept(t, u);
+ } catch (Throwable ex) {
+ rethrowUnchecked(ex);
+ }
+ };
+ }
+ }
+
+ @FunctionalInterface
public interface ThrowingSupplier<T> {
T get() throws Throwable;
public static <T> Supplier<T> toSupplier(ThrowingSupplier<T> v) {
return () -> {
*** 100,109 ****
--- 112,125 ----
public static <T> Consumer<T> identity(Consumer<T> v) {
return v;
}
+ public static <T, U> BiConsumer<T, U> identity(BiConsumer<T, U> v) {
+ return v;
+ }
+
public static Runnable identity(Runnable v) {
return v;
}
public static <T, R> Function<T, R> identity(Function<T, R> v) {
< prev index next >