Class IOUtils
- java.lang.Object
-
- org.jenkinsci.plugins.github.pullrequest.utils.IOUtils
-
public class IOUtils extends Object
Utilities for IOException handling in Streams
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
IOUtils.IOFunction<T,R>
static interface
IOUtils.IOPredicate<T>
static interface
IOUtils.IOSupplier<T>
static class
IOUtils.RuntimeIOException
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V> void
forEachIo(Stream<V> stream, Consumer<V> cons)
Executes aStream.forEach(Consumer)
on a stream that uses IO-versions of lambdas and spits out any thrown IOExceptionstatic <T,R>
Function<T,R>iof(IOUtils.IOFunction<T,R> fun)
Wraps provided Function into an IOFunction.static <V> Stream<V>
ioOptStream(IOUtils.IOSupplier<V> supp)
Creates a stream from a single element returned by provided IOSupplier.static <T> Predicate<T>
iop(IOUtils.IOPredicate<T> pred)
Wraps provided Predicate into an IOPredicate.static void
withIo(Runnable run)
Executes a terminal operation that uses IO-versions of lambdas and spits out any thrown IOExceptionstatic <V> V
withIo(Supplier<V> supp)
Executes a terminal operation that uses IO-versions of lambdas and spits out any thrown IOException
-
-
-
Method Detail
-
iof
public static <T,R> Function<T,R> iof(IOUtils.IOFunction<T,R> fun)
Wraps provided Function into an IOFunction. Users are expected to wrap stream terminal operations usingwithIo(Runnable)
orwithIo(Supplier)
-
iop
public static <T> Predicate<T> iop(IOUtils.IOPredicate<T> pred)
Wraps provided Predicate into an IOPredicate. Users are expected to wrap stream terminal operations usingwithIo(Runnable)
orwithIo(Supplier)
-
withIo
public static <V> V withIo(Supplier<V> supp) throws IOException
Executes a terminal operation that uses IO-versions of lambdas and spits out any thrown IOException- Throws:
IOException
-
withIo
public static void withIo(Runnable run) throws IOException
Executes a terminal operation that uses IO-versions of lambdas and spits out any thrown IOException- Throws:
IOException
-
forEachIo
public static <V> void forEachIo(Stream<V> stream, Consumer<V> cons) throws IOException
Executes aStream.forEach(Consumer)
on a stream that uses IO-versions of lambdas and spits out any thrown IOException- Throws:
IOException
-
ioOptStream
public static <V> Stream<V> ioOptStream(IOUtils.IOSupplier<V> supp)
Creates a stream from a single element returned by provided IOSupplier. If supplier throws an IOException, returnsStream.empty()
-
-