fj.data.IOW Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functionaljava Show documentation
Show all versions of functionaljava Show documentation
Functional Java is an open source library that supports closures for the Java programming language
package fj.data;
import fj.F;
import fj.Unit;
import java.io.IOException;
/**
* Created by MarkPerry on 9/06/2015.
*/
public final class IOW implements IO {
private final IO io;
private IOW(IO in) {
io = in;
}
public static IOW lift(IO io) {
return new IOW<>(io);
}
@Override
public A run() throws IOException {
return io.run();
}
public SafeIO> safe() {
return IOFunctions.toSafeValidation(io);
}
public IOW map(F f) { return lift(IOFunctions.map(io, f)); }
public IOW bind(F> f) { return lift(IOFunctions.bind(io, f)); }
public IOW append(IO iob) { return lift(IOFunctions.append(io, iob)); }
public static IOW getContents() {
return lift(() -> IOFunctions.getContents().run());
}
public static IOW interact(F f) {
return lift(() -> IOFunctions.interact(f).run());
}
}