net.mintern.functions.ternary.DblObjIntToBool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of functions-ternary-core Show documentation
Show all versions of functions-ternary-core Show documentation
Provides functional interfaces for the most commonly used two-argument functions
The newest version!
package net.mintern.functions.ternary;
/**
* An operation of type {@code (double, U, int) -> boolean}.
*
* @param the type of the argument
*/
@FunctionalInterface
public interface DblObjIntToBool extends
net.mintern.functions.ternary.checked.DblObjIntToBoolE {
/**
* Returns a wrapped version of {@code f} that uses {@code toRuntime} to convert any checked
* {@code Exception} to a {@code RuntimeException}.
*
* @param the type of argument 2
* @param the {@code Exception} type that the operation may throw
* @param toRuntime if a checked exception is thrown from
* {@link net.mintern.functions.ternary.checked.DblObjIntToBoolE#call}, then this function
* is called in in order to convert it to a {@code RuntimeException}
* @param f the operation to wrap
* @return a wrapped version of {@code f} that does not throw checked exceptions
*/
@SuppressWarnings("unchecked")
static DblObjIntToBool unchecked(
java.util.function.Function super E, RuntimeException> toRuntime,
net.mintern.functions.ternary.checked.DblObjIntToBoolE f) {
return (d, u, i) -> {
try {
return f.call(d, u, i);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw toRuntime.apply((E) e);
}
};
}
/**
* Returns a wrapped version of {@code f} that wraps any checked {@code Exception} with a
* {@code RuntimeException}.
*
* @param the type of argument 2
* @param the {@code Exception} type that the operation may throw
* @param f the operation to wrap
* @return a wrapped version of {@code f} that does not throw checked exceptions
*/
static DblObjIntToBool unchecked(
net.mintern.functions.ternary.checked.DblObjIntToBoolE f) {
return unchecked(RuntimeException::new, f);
}
/**
* Returns a wrapped version of {@code f} that wraps any {@code IOException} with an
* {@link java.io.UncheckedIOException}.
*
* @param the type of argument 2
* @param the {@code Exception} type that the operation may throw
* @param f the operation to wrap
* @return a wrapped version of {@code f} that throws {@code UncheckedIOException} instead of
* {@code IOException}
*/
static DblObjIntToBool uncheckedIO(
net.mintern.functions.ternary.checked.DblObjIntToBoolE f) {
return unchecked(java.io.UncheckedIOException::new, f);
}
/**
* Binds {@code (d)} to the beginning of {@code f}, returning a new function
* of type {@code (U, int) -> boolean}.
*
* @param the type of the argument
* @param f the unbound function
* @param d argument 1
* @return a new function {@code (U u, int i) -> boolean} that calls
* {@code f.call(d, u, i)} and returns the result.
*/
static net.mintern.functions.binary.ObjIntToBool
bind(DblObjIntToBool f, double d) {
return (u, i) -> f.call(d, u, i);
}
/**
* Binds {@code (d)} to the beginning of {@code this}, returning a new function
* of type {@code (U, int) -> boolean}.
*
* @param d argument 1
* @return a new function {@code (U u, int i) -> boolean} that calls
* {@code this.call(d, u, i)} and returns the result.
*/
@Override
default net.mintern.functions.binary.ObjIntToBool bind(double d) {
return DblObjIntToBool.bind(this, d);
}
/**
* Binds {@code (u, i)} to the end of {@code f}, returning a new function
* of type {@code (double) -> boolean}.
*
* @param the type of the argument
* @param f the unbound function
* @param u argument 2
* @param i argument 3
* @return a new function {@code (double d) -> boolean} that calls
* {@code f.call(d, u, i)} and returns the result.
*/
static net.mintern.functions.unary.DblToBool
rbind(DblObjIntToBool f, U u, int i) {
return (d) -> f.call(d, u, i);
}
/**
* Binds {@code (u, i)} to the end of {@code this}, returning a new function
* of type {@code (double) -> boolean}.
*
* @param u argument 2
* @param i argument 3
* @return a new function {@code (double d) -> boolean} that calls
* {@code this.call(d, u, i)} and returns the result.
*/
@Override
default net.mintern.functions.unary.DblToBool rbind(U u, int i) {
return DblObjIntToBool.rbind(this, u, i);
}
/**
* Binds {@code (d, u)} to the beginning of {@code f}, returning a new function
* of type {@code (int) -> boolean}.
*
* @param the type of the argument
* @param f the unbound function
* @param d argument 1
* @param u argument 2
* @return a new function {@code (int i) -> boolean} that calls
* {@code f.call(d, u, i)} and returns the result.
*/
static net.mintern.functions.unary.IntToBool
bind(DblObjIntToBool f, double d, U u) {
return (i) -> f.call(d, u, i);
}
/**
* Binds {@code (d, u)} to the beginning of {@code this}, returning a new function
* of type {@code (int) -> boolean}.
*
* @param d argument 1
* @param u argument 2
* @return a new function {@code (int i) -> boolean} that calls
* {@code this.call(d, u, i)} and returns the result.
*/
@Override
default net.mintern.functions.unary.IntToBool bind(double d, U u) {
return DblObjIntToBool.bind(this, d, u);
}
/**
* Binds {@code (i)} to the end of {@code f}, returning a new function
* of type {@code (double, U) -> boolean}.
*
* @param the type of the argument
* @param f the unbound function
* @param i argument 3
* @return a new function {@code (double d, U u) -> boolean} that calls
* {@code f.call(d, u, i)} and returns the result.
*/
static net.mintern.functions.binary.DblObjToBool
rbind(DblObjIntToBool f, int i) {
return (d, u) -> f.call(d, u, i);
}
/**
* Binds {@code (i)} to the end of {@code this}, returning a new function
* of type {@code (double, U) -> boolean}.
*
* @param i argument 3
* @return a new function {@code (double d, U u) -> boolean} that calls
* {@code this.call(d, u, i)} and returns the result.
*/
@Override
default net.mintern.functions.binary.DblObjToBool rbind(int i) {
return DblObjIntToBool.rbind(this, i);
}
/**
* Binds {@code (d, u, i)} to {@code f}, returning a new function
* of type {@code () -> boolean}.
*
* @param the type of the argument
* @param f the unbound function
* @param d argument 1
* @param u argument 2
* @param i argument 3
* @return a new function {@code () -> boolean} that calls
* {@code f.call(d, u, i)} and returns the result.
*/
static net.mintern.functions.nullary.NilToBool
bind(DblObjIntToBool f, double d, U u, int i) {
return () -> f.call(d, u, i);
}
/**
* Binds {@code (d, u, i)} to {@code this}, returning a new function
* of type {@code () -> boolean}.
*
* @param d argument 1
* @param u argument 2
* @param i argument 3
* @return a new function {@code () -> boolean} that calls
* {@code this.call(d, u, i)} and returns the result.
*/
@Override
default net.mintern.functions.nullary.NilToBool bind(double d, U u, int i) {
return DblObjIntToBool.bind(this, d, u, i);
}
}