A
- the initial AutoCloseable
value type to map and clean upB
- the resulting typepublic final class AutoBracket<A extends AutoCloseable,B> extends Object implements Fn2<IO<A>,Fn1<? super A,? extends IO<B>>,IO<B>>
IO
yielding some AutoCloseable
type A
and a kleisli arrow from that type to a
new IO
of type B
, attempt to provision the A
, applying the body operation if
provisioning was successful and ensuring that AutoCloseable.close()
is called regardless of whether the body
succeeds or fails.
This is the canonical bracketing
operation for AutoCloseables
.
Bracket
Modifier and Type | Method and Description |
---|---|
static <A extends AutoCloseable,B> |
autoBracket() |
static <A extends AutoCloseable,B> |
autoBracket(IO<A> io) |
static <A extends AutoCloseable,B> |
autoBracket(IO<A> io,
Fn1<? super A,? extends IO<B>> bodyIO) |
IO<B> |
checkedApply(IO<A> io,
Fn1<? super A,? extends IO<B>> bodyIO) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
apply, apply, checkedApply, compose, contraMap, curried, curry, diMapL, discardR, flip, fn2, fromBiFunction, toBiFunction, uncurry, widen
public IO<B> checkedApply(IO<A> io, Fn1<? super A,? extends IO<B>> bodyIO)
checkedApply
in interface Fn2<IO<A extends AutoCloseable>,Fn1<? super A extends AutoCloseable,? extends IO<B>>,IO<B>>
public static <A extends AutoCloseable,B> AutoBracket<A,B> autoBracket()
public static <A extends AutoCloseable,B> Fn1<Fn1<? super A,? extends IO<B>>,IO<B>> autoBracket(IO<A> io)
public static <A extends AutoCloseable,B> IO<B> autoBracket(IO<A> io, Fn1<? super A,? extends IO<B>> bodyIO)