Interface Checked<WT,EX extends Throwable>
- Type Parameters:
WT- The type this functional interface can be wrapped as by ederWrap(), which may be a corresponding Java functional interface that does not allow checked exceptions.EX- The checked exception type (or least upper bound of the checked exception types) that the body of this functional interface may throw.
- All Known Subinterfaces:
Checked.BiConsumer<T,,U, E> Checked.BooleanConsumer<E>,Checked.BooleanSupplier<E>,Checked.ByteConsumer<E>,Checked.ByteSupplier<E>,Checked.CharConsumer<E>,Checked.CharSupplier<E>,org.postgresql.pljava.internal.Checked.Closing.Trivial<WT,,EX> Checked.Consumer<T,,E> Checked.DoubleConsumer<E>,Checked.DoubleSupplier<E>,Checked.FloatConsumer<E>,Checked.FloatSupplier<E>,Checked.Function<T,,R, E> Checked.IntConsumer<E>,Checked.IntSupplier<E>,Checked.LongConsumer<E>,Checked.LongSupplier<E>,Checked.Predicate<T,,E> Checked.Runnable<E>,Checked.ShortConsumer<E>,Checked.ShortSupplier<E>,Checked.Supplier<T,,E> Checked.ToByteFunction<T,,E> Checked.ToCharFunction<T,,E> Checked.ToDoubleFunction<T,,E> Checked.ToFloatFunction<T,,E> Checked.ToIntFunction<T,,E> Checked.ToLongFunction<T,,E> Checked.ToShortFunction<T,E>
It would be ideal if the compiler could preserve its union of possible
thrown types as the inferred exception type of the functional interface
method. Instead, it collapses the union to the nearest common supertype,
which is less useful, as it becomes Exception rather quickly if
the lambda can throw a few unrelated exceptions. It is still useful for
short lambdas that throw only a few related exceptions.
Also, the Java API lacks primitive
Consumer/Supplier/Optional types for byte,
short, char, float, and some of them for
boolean. To allow a more orthogonal API for access to datum values,
those are provided here, again supporting checked exceptions. Because these
"bonus" types do not have checked-exception-less counterparts in the Java
API, they do not strictly need the wrapper methods described next.
For interoperating with Java APIs that require the Java no-checked-exceptions
versions of these interfaces, each checked interface here (for which a Java
API no-checked version exists) has an ederWrap method that produces
the Java no-checked version of the same interface, using a lightweight idiom
advanced by Lukas Eder, developer of jOOλ. The checked exception is not
wrapped, but simply flown under javac's radar. That idiom is extended
here with a corresponding in method to pass the wrapped interface
into code that requires it, re-exposing the checked exception type. That
makes possible constructions like:
Stream<String> strs = ...;
Writer w = ...;
try {
Checked.Consumer.use((String s) -> w.write(s)) // throws IOException!
.in(c -> strs.forEach(c));
}
catch ( IOException e ) { ... }
where the Stream.forEach method requires a Java Consumer
that declares no checked exceptions.
Such an idiom is, of course, contrary to an SEI CERT coding standard,
and likely to produce surprises if the exception will be 'flown' through deep
layers of code by others that may contain catch blocks. That said, as
a convenience for dealing with checked exceptions and simple Java APIs that
cannot accept them, it can be useful as long as the intervening code through
which the exception may be 'flown' is simple and short.
The functional interfaces defined here that do not correspond to a
Java API no-checked version, while not strictly needing an ederWrap
method, have one anyway, a no-op identity function. That avoids arbitrary
limits on which ones can participate in the use(...).in(...) idiom.
Static composed() methods are provided here in place of the instance
compose or andThen methods in Java's function API, which seem
to challenge javac's type inference when exception types are thrown
in. A static composed method can substitute for compose or
andThen, by ordering the parameters as desired. Likewise, static
and and or methods are provided in place of the instance
methods on Java's Predicate.
Each functional interface declared here has a static use(...) method
that can serve, as a concise alternative to casting, to constrain the type
of a lambda expression when the compiler won't infer it.
A variant of AutoCloseable with an exception-type
parameter, and some closing methods (inspired
by Python, for use with resources that do not already implement
AutoCloseable), are also provided.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceChecked.AutoCloseable<E extends Exception>Version ofAutoCloseablewith an exception-type parameter.static interfaceChecked.BiConsumer<T,U, E extends Throwable> LikeBiConsumerbut with a body that can throw checked exceptions.static interfaceChecked.BooleanConsumer<E extends Throwable>Represents an operation that accepts a single boolean-valued argument and can throw checked exceptions.static interfaceChecked.BooleanSupplier<E extends Throwable>LikeBooleanSupplierbut with a body that can throw checked exceptions.static interfaceChecked.ByteConsumer<E extends Throwable>Represents an operation that accepts a single byte-valued argument and can throw checked exceptions.static interfaceChecked.ByteSupplier<E extends Throwable>A supplier of byte-valued results, with a body that can throw checked exceptions.static interfaceChecked.CharConsumer<E extends Throwable>Represents an operation that accepts a single char-valued argument and can throw checked exceptions.static interfaceChecked.CharSupplier<E extends Throwable>A supplier of char-valued results, with a body that can throw checked exceptions.static classChecked.Closing<T,E extends Exception> A class that can supply aTwhile also implementingAutoCloseable<E>; suitable for use in atry-with-resources to wrap some value that does not itself implementAutoCloseable.static interfaceChecked.Consumer<T,E extends Throwable> LikeConsumerbut with a body that can throw checked exceptions.static interfaceChecked.DoubleConsumer<E extends Throwable>LikeDoubleConsumerbut with a body that can throw checked exceptions.static interfaceChecked.DoubleSupplier<E extends Throwable>LikeDoubleSupplierbut with a body that can throw checked exceptions.static interfaceChecked.FloatConsumer<E extends Throwable>Represents an operation that accepts a single float-valued argument and can throw checked exceptions.static interfaceChecked.FloatSupplier<E extends Throwable>A supplier of float-valued results, with a body that can throw checked exceptions.static interfaceChecked.Function<T,R, E extends Throwable> LikeFunctionbut with a body that can throw checked exceptions.static interfaceChecked.IntConsumer<E extends Throwable>LikeIntConsumerbut with a body that can throw checked exceptions.static interfaceChecked.IntSupplier<E extends Throwable>LikeIntSupplierbut with a body that can throw checked exceptions.static interfaceChecked.LongConsumer<E extends Throwable>LikeLongConsumerbut with a body that can throw checked exceptions.static interfaceChecked.LongSupplier<E extends Throwable>LikeLongSupplierbut with a body that can throw checked exceptions.static classHead of a family ofOptional-like types covering the Java primitives that thejava.util.Optional...classes do not cover, and whose methods that expect functional interfaces will accept the checked-exception versions declared here.static classA container object which may or may not contain abooleanvalue.static classA container object which may or may not contain abytevalue.static classA container object which may or may not contain acharvalue.static classA container object which may or may not contain afloatvalue.static classA container object which may or may not contain ashortvalue.static interfaceChecked.Predicate<T,E extends Throwable> LikePredicatebut with a body that can throw checked exceptions.static interfaceChecked.Runnable<E extends Throwable>LikeRunnablebut with a body that can throw checked exceptions.static interfaceChecked.ShortConsumer<E extends Throwable>Represents an operation that accepts a single short-valued argument and can throw checked exceptions.static interfaceChecked.ShortSupplier<E extends Throwable>A supplier of short-valued results, with a body that can throw checked exceptions.static interfaceChecked.Supplier<T,E extends Throwable> LikeSupplierbut with a body that can throw checked exceptions.static interfaceChecked.ToByteFunction<T,E extends Throwable> Represents a function that produces a byte-valued result and can throw checked exceptions.static interfaceChecked.ToCharFunction<T,E extends Throwable> Represents a function that produces a char-valued result and can throw checked exceptions.static interfaceChecked.ToDoubleFunction<T,E extends Throwable> LikeToDoubleFunctionbut with a body that can throw checked exceptions.static interfaceChecked.ToFloatFunction<T,E extends Throwable> Represents a function that produces a float-valued result and can throw checked exceptions.static interfaceChecked.ToIntFunction<T,E extends Throwable> LikeToIntFunctionbut with a body that can throw checked exceptions.static interfaceChecked.ToLongFunction<T,E extends Throwable> LikeToLongFunctionbut with a body that can throw checked exceptions.static interfaceChecked.ToShortFunction<T,E extends Throwable> Represents a function that produces a short-valued result and can throw checked exceptions. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T,E extends Throwable>
Checked.Predicate<T, E> and(Checked.Predicate<? super T, ? extends E> first, Checked.Predicate<? super T, ? extends E> after) Returns aPredicatethat is the short-circuitingANDof two others.static <E extends Exception>
Checked.AutoCloseable<E> closing(Checked.AutoCloseable<E> o) Returns its argument; shorthand for casting a suitable lambda toAutoCloseable<E>.static <T,S extends BaseStream<T, S>, E extends Exception>
Checked.Closing<S, E> closing(S stream, Checked.Runnable<E> closer) Given a stream and a lambda that should be invoked when it is closed, construct a new stream that runs that lambda when closed, and return aClosinginstance with the new stream as its payload, which will be closed by thecloseaction.static <T,E extends Exception>
Checked.Closing<T, E> closing(T payload, Checked.AutoCloseable<E> closer) Wrap some payload and a 'closer' lambda as aClosinginstance that can supply the payload and implementsAutoCloseableusing the lambda; useful in atry-with-resources when the payload itself does not implementAutoCloseable.static <T,U, E extends Throwable>
Checked.BiConsumer<T, U, E> composed(Checked.BiConsumer<? super T, ? super U, ? extends E> first, Checked.BiConsumer<? super T, ? super U, ? extends E> after) Returns aBiConsumerthat is the composition of two others.static <T,E extends Throwable>
Checked.Consumer<T, E> composed(Checked.Consumer<? super T, ? extends E> first, Checked.Consumer<? super T, ? extends E> after) Returns aConsumerthat is the composition of two others.static <E extends Throwable>
Checked.DoubleConsumer<E> composed(Checked.DoubleConsumer<? extends E> first, Checked.DoubleConsumer<? extends E> after) Returns aDoubleConsumerthat is the composition of two others.static <T,R, V, E extends Throwable>
Checked.Function<T, R, E> composed(Checked.Function<? super T, ? extends V, ? extends E> first, Checked.Function<? super V, ? extends R, ? extends E> after) Returns aFunctionthat is the composition of two others.static <E extends Throwable>
Checked.IntConsumer<E> composed(Checked.IntConsumer<? extends E> first, Checked.IntConsumer<? extends E> after) Returns anIntConsumerthat is the composition of two others.static <E extends Throwable>
Checked.LongConsumer<E> composed(Checked.LongConsumer<? extends E> first, Checked.LongConsumer<? extends E> after) Returns aLongConsumerthat is the composition of two others.static <E extends Throwable>
EThrow an exception, unsafely cast to a different exception type, chiefly as used by Lukas Eder to fly a checked exception through a section of code that does not accept it.ederWrap()Wraps thisCheckedfunctional interfaces as its corresponding Java functional interfaceWT, which possibly does not allow checked exceptions.default <RX extends Throwable>
voidin(Checked.Consumer<? super WT, RX> c) Passes this functional interface, wrapped as its wrapper typeWT, into a code body that requires that wrapper type, while remembering for the compiler the checked exception type that may, in fact, be thrown.default <RX extends Throwable>
booleaninBooleanReturning(Checked.Predicate<? super WT, RX> f) Likein(...)but where the body returns aboolean.default <RX extends Throwable>
byteinByteReturning(Checked.ToByteFunction<? super WT, RX> f) Likein(...)but where the body returns abyte.default <RX extends Throwable>
charinCharReturning(Checked.ToCharFunction<? super WT, RX> f) Likein(...)but where the body returns achar.default <RX extends Throwable>
doubleinDoubleReturning(Checked.ToDoubleFunction<? super WT, RX> f) Likein(...)but where the body returns adouble.default <RX extends Throwable>
floatinFloatReturning(Checked.ToFloatFunction<? super WT, RX> f) Likein(...)but where the body returns afloat.default <RX extends Throwable>
intinIntReturning(Checked.ToIntFunction<? super WT, RX> f) Likein(...)but where the body returns anint.default <RX extends Throwable>
longinLongReturning(Checked.ToLongFunction<? super WT, RX> f) Likein(...)but where the body returns along.default <RT,RX extends Throwable>
RTinReturning(Checked.Function<? super WT, RT, RX> f) Likein(...)but where the body returns a non-primitive type.default <RX extends Throwable>
shortinShortReturning(Checked.ToShortFunction<? super WT, RX> f) Likein(...)but where the body returns ashort.static <T,E extends Throwable>
Checked.Predicate<T, E> or(Checked.Predicate<? super T, ? extends E> first, Checked.Predicate<? super T, ? extends E> after) Returns aPredicatethat is the short-circuitingORof two others.
-
Method Details
-
ederThrow
Throw an exception, unsafely cast to a different exception type, chiefly as used by Lukas Eder to fly a checked exception through a section of code that does not accept it.In PL/Java, this method is not intended to be called directly, but used transparently within the
in(...)construct, which re-exposes the checked exception typeEXto the compiler.- Type Parameters:
E- The throwable type the argument t should be presented as.- Parameters:
t- A throwable.- Throws:
E- The argument t, represented to the compiler as of type E.
-
ederWrap
WT ederWrap()Wraps thisCheckedfunctional interfaces as its corresponding Java functional interfaceWT, which possibly does not allow checked exceptions.Checked exceptions of type
EXmay still, in reality, be thrown. This method is not intended to be called directly; it is used transparently byin(...), which passes the wrapper type into code that requires it, but re-exposes the original checked exception type to the compiler. -
in
Passes this functional interface, wrapped as its wrapper typeWT, into a code body that requires that wrapper type, while remembering for the compiler the checked exception type that may, in fact, be thrown.- Type Parameters:
RX- Any exception type that the body, c, detectably can throw.- Parameters:
c- A Consumer to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body c.
-
inReturning
default <RT,RX extends Throwable> RT inReturning(Checked.Function<? super WT, RT, throws EX, RXRX> f) Likein(...)but where the body returns a non-primitive type.- Type Parameters:
RT- Return type of the body f.RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToDoubleFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inDoubleReturning
default <RX extends Throwable> double inDoubleReturning(Checked.ToDoubleFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns adouble.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToDoubleFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inIntReturning
default <RX extends Throwable> int inIntReturning(Checked.ToIntFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns anint.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToIntFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inLongReturning
default <RX extends Throwable> long inLongReturning(Checked.ToLongFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns along.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToLongFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inBooleanReturning
default <RX extends Throwable> boolean inBooleanReturning(Checked.Predicate<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns aboolean.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A Predicate to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inByteReturning
default <RX extends Throwable> byte inByteReturning(Checked.ToByteFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns abyte.This method is provided for consistency of notation, even though it is not strictly needed because Java has no checked-exception-less counterpart of
ToByteFunction.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToByteFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inShortReturning
default <RX extends Throwable> short inShortReturning(Checked.ToShortFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns ashort.This method is provided for consistency of notation, even though it is not strictly needed because Java has no checked-exception-less counterpart of
ToShortFunction.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToShortFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inCharReturning
default <RX extends Throwable> char inCharReturning(Checked.ToCharFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns achar.This method is provided for consistency of notation, even though it is not strictly needed because Java has no checked-exception-less counterpart of
ToCharFunction.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToCharFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
inFloatReturning
default <RX extends Throwable> float inFloatReturning(Checked.ToFloatFunction<? super WT, RX> f) throws EX, RXLikein(...)but where the body returns afloat.This method is provided for consistency of notation, even though it is not strictly needed because Java has no checked-exception-less counterpart of
ToFloatFunction.- Type Parameters:
RX- Any exception type that the body, f, detectably can throw.- Parameters:
f- A ToFloatFunction to which this instance, wrapped as its corresponding functional interface WT, will be passed.- Throws:
EX- whatever can be thrown by the body of this instanceRX- whatever can be thrown by the body f.
-
and
static <T,E extends Throwable> Checked.Predicate<T,E> and(Checked.Predicate<? super T, ? extends E> first, Checked.Predicate<? super T, ? extends E> after) Returns aPredicatethat is the short-circuitingANDof two others.- Type Parameters:
T- Greatest-lower-bound parameter type acceptable to first and after, and the parameter type of the resulting predicate.E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting predicate.- Parameters:
first- The predicate to be tested first.after- The predicate to be tested next.
-
or
static <T,E extends Throwable> Checked.Predicate<T,E> or(Checked.Predicate<? super T, ? extends E> first, Checked.Predicate<? super T, ? extends E> after) Returns aPredicatethat is the short-circuitingORof two others.- Type Parameters:
T- Greatest-lower-bound parameter type acceptable to first and after, and the parameter type of the resulting predicate.E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting predicate.- Parameters:
first- The predicate to be tested first.after- The predicate to be tested next.
-
composed
static <T,R, Checked.Function<T,V, E extends Throwable> R, composedE> (Checked.Function<? super T, ? extends V, ? extends E> first, Checked.Function<? super V, ? extends R, ? extends E> after) Returns aFunctionthat is the composition of two others.- Type Parameters:
T- Parameter type of the resulting function, and acceptable as parameter of first.R- Return type of the composed function, subsuming the return type of after.V- Type subsuming the return type of first, and acceptable as parameter of after.E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting function.- Parameters:
first- The first function to be applied.after- The function applied to the result of first.
-
composed
static <T,U, Checked.BiConsumer<T,E extends Throwable> U, composedE> (Checked.BiConsumer<? super T, ? super U, ? extends E> first, Checked.BiConsumer<? super T, ? super U, ? extends E> after) Returns aBiConsumerthat is the composition of two others.- Type Parameters:
T- First parameter type of the resulting BiConsumer, acceptable as first parameter to both first and after.U- Second parameter type of the resulting BiConsumer, acceptable as second parameter to both first and after.E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting biconsumer.- Parameters:
first- The first consumer to be applied.after- The consumer next applied to the same inputs.
-
composed
static <T,E extends Throwable> Checked.Consumer<T,E> composed(Checked.Consumer<? super T, ? extends E> first, Checked.Consumer<? super T, ? extends E> after) Returns aConsumerthat is the composition of two others.- Type Parameters:
T- Parameter type of the resulting Consumer, acceptable as parameter to both first and after.E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting consumer.- Parameters:
first- The first consumer to be applied.after- The consumer next applied to the same input.
-
composed
static <E extends Throwable> Checked.DoubleConsumer<E> composed(Checked.DoubleConsumer<? extends E> first, Checked.DoubleConsumer<? extends E> after) Returns aDoubleConsumerthat is the composition of two others.- Type Parameters:
E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting consumer.- Parameters:
first- The first consumer to be applied.after- The consumer next applied to the same input.
-
composed
static <E extends Throwable> Checked.IntConsumer<E> composed(Checked.IntConsumer<? extends E> first, Checked.IntConsumer<? extends E> after) Returns anIntConsumerthat is the composition of two others.- Type Parameters:
E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting consumer.- Parameters:
first- The first consumer to be applied.after- The consumer next applied to the same input.
-
composed
static <E extends Throwable> Checked.LongConsumer<E> composed(Checked.LongConsumer<? extends E> first, Checked.LongConsumer<? extends E> after) Returns aLongConsumerthat is the composition of two others.- Type Parameters:
E- Least upper bound of the exception types thrown by first and after, representing the exception types thrown by the resulting consumer.- Parameters:
first- The first consumer to be applied.after- The consumer next applied to the same input.
-
closing
Returns its argument; shorthand for casting a suitable lambda toAutoCloseable<E>.Where some resource does not itself implement
AutoCloseable, an idiom like the following, inspired by Python, can be used in Java 10 or later, and the compiler will infer that it can throw whateverthing.release()can throw:try(var ac = closing(() -> { thing.release(); })) { ... }Pre-Java 10, without
var, you have to specify the exception type, but you still get the simple idiom without needing to declare some new interface:try(Checked.AutoCloseable<ThingException> ac = closing(() -> { thing.release(); })) { ... }- Type Parameters:
E- Least upper bound of exceptions that can be thrown by o- Parameters:
o- Lambda or method reference to serve as the close operation.
-
closing
static <T,E extends Exception> Checked.Closing<T,E> closing(T payload, Checked.AutoCloseable<E> closer) Wrap some payload and a 'closer' lambda as aClosinginstance that can supply the payload and implementsAutoCloseableusing the lambda; useful in atry-with-resources when the payload itself does not implementAutoCloseable.- Type Parameters:
T- Type of the payload.E- Least upper bound of exceptions that may be thrown at close.- Parameters:
payload- Any object.closer- Lambda or method reference to serve as the close operation.
-
closing
static <T,S extends BaseStream<T, Checked.Closing<S,S>, E extends Exception> E> closing(S stream, Checked.Runnable<E> closer) Given a stream and a lambda that should be invoked when it is closed, construct a new stream that runs that lambda when closed, and return aClosinginstance with the new stream as its payload, which will be closed by thecloseaction.Intended for use in a
try-with-resources. Any checked exception throwable by closer will be remembered as throwable by theclosemethod of the returnedClosinginstance (and therefore will be considered throwable by thetry-with-resources in which it is used. Any other code that callsclosedirectly on the returned stream could be surprised by the checked exception, as a stream'sclosemethod is not declared to throw any. When used as intended in atry-with-resources, any such surprise is bounded by the scope of that statement.- Type Parameters:
T- Type of the stream elementsS- Type of the streamE- Least upper bound of exceptions that can be thrown by closer, and the declared throwable type of the close method of the returned Closing instance.- Parameters:
stream- Stream to have closer added as an action on close.closer- Runnable to be executed when the returned stream is closed.
-