
com.github.dakusui.thincrest_pcond.forms.Printables Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thincrest-pcond Show documentation
Show all versions of thincrest-pcond Show documentation
Yet another assertion library powered by "pcond"
The newest version!
package com.github.dakusui.thincrest_pcond.forms;
import com.github.dakusui.thincrest_pcond.core.printable.PrintableFunctionFactory;
import com.github.dakusui.thincrest_pcond.core.printable.PrintablePredicateFactory;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
/**
* An entry point class that provides methods to create a new "printable" function from a given conventional function.
*/
public enum Printables {
;
/**
* Returns a printable predicate for a given one.
* This is a short hand of `Printables.predicate(() -> name, predicate)`.
*
* @param name A name of the returned predicate.
* @param predicate A predicate from which a printable predicate is created.
* @param The type that the returned predicate can test.
* @return A printable predicate.
*/
public static Predicate predicate(String name, Predicate predicate) {
return PrintablePredicateFactory.leaf(name, predicate);
}
/**
* Returns a printable predicate for a given one.
*
* @param formatter A supplier that gives a string printed on `toString()`.
* @param predicate A predicate from which a printable predicate is created.
* @param The type that the returned predicate can test.
* @return A printable predicate.
*/
public static Predicate predicate(Supplier formatter, Predicate predicate) {
return PrintablePredicateFactory.leaf(formatter, predicate);
}
/**
* Returns a printable function for a given one.
* This is a short-hand method for `Printables.function(() -> name, function)`.
*
* @param name A name of the function.
* @param function A function from which a printable function is created.
* @param A type of the function's parameter.
* @param A type of the function's returned value.
* @return A printable function.
*/
public static Function function(String name, Function function) {
return PrintableFunctionFactory.function(name, function);
}
/**
* Returns a printable function for a given one.
*
* @param formatter A supplier that gives a string printed on `toString()`.
* @param function A function from which a printable function is created.
* @param A type of the function's parameter.
* @param A type of the function's returned value.
* @return A printable function.
*/
public static Function function(Supplier formatter, Function function) {
return PrintableFunctionFactory.function(formatter, function);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy