| 1 | package com.github.dakusui.pcond.forms; | |
| 2 | ||
| 3 | ||
| 4 | import com.github.dakusui.pcond.core.printable.PrintableFunctionFactory; | |
| 5 | import com.github.dakusui.pcond.core.printable.PrintablePredicateFactory; | |
| 6 | ||
| 7 | import java.util.function.Function; | |
| 8 | import java.util.function.Predicate; | |
| 9 | import java.util.function.Supplier; | |
| 10 | ||
| 11 | /** | |
| 12 | * An entry point class that provides methods to create a new "printable" function from a given conventional function. | |
| 13 | */ | |
| 14 | public enum Printables { | |
| 15 | ; | |
| 16 | | |
| 17 | /** | |
| 18 | * Returns a printable predicate for a given one. | |
| 19 | * This is a short hand of `Printables.predicate(() -> name, predicate)`. | |
| 20 | * | |
| 21 | * @param name A name of the returned predicate. | |
| 22 | * @param predicate A predicate from which a printable predicate is created. | |
| 23 | * @param <T> The type that the returned predicate can test. | |
| 24 | * @return A printable predicate. | |
| 25 | */ | |
| 26 | public static <T> Predicate<T> predicate(String name, Predicate<T> predicate) { | |
| 27 |
1
1. predicate : replaced return value with null for com/github/dakusui/pcond/forms/Printables::predicate → KILLED |
return PrintablePredicateFactory.leaf(name, predicate); |
| 28 | } | |
| 29 | | |
| 30 | /** | |
| 31 | * Returns a printable predicate for a given one. | |
| 32 | * | |
| 33 | * @param formatter A supplier that gives a string printed on `toString()`. | |
| 34 | * @param predicate A predicate from which a printable predicate is created. | |
| 35 | * @param <T> The type that the returned predicate can test. | |
| 36 | * @return A printable predicate. | |
| 37 | */ | |
| 38 | public static <T> Predicate<T> predicate(Supplier<String> formatter, Predicate<T> predicate) { | |
| 39 |
1
1. predicate : replaced return value with null for com/github/dakusui/pcond/forms/Printables::predicate → KILLED |
return PrintablePredicateFactory.leaf(formatter, predicate); |
| 40 | } | |
| 41 | | |
| 42 | /** | |
| 43 | * Returns a printable function for a given one. | |
| 44 | * This is a short-hand method for `Printables.function(() -> name, function)`. | |
| 45 | * | |
| 46 | * @param name A name of the function. | |
| 47 | * @param function A function from which a printable function is created. | |
| 48 | * @param <T> A type of the function's parameter. | |
| 49 | * @param <R> A type of the function's returned value. | |
| 50 | * @return A printable function. | |
| 51 | */ | |
| 52 | public static <T, R> Function<T, R> function(String name, Function<T, R> function) { | |
| 53 |
1
1. function : replaced return value with null for com/github/dakusui/pcond/forms/Printables::function → KILLED |
return PrintableFunctionFactory.function(name, function); |
| 54 | } | |
| 55 | | |
| 56 | /** | |
| 57 | * Returns a printable function for a given one. | |
| 58 | * | |
| 59 | * @param formatter A supplier that gives a string printed on `toString()`. | |
| 60 | * @param function A function from which a printable function is created. | |
| 61 | * @param <T> A type of the function's parameter. | |
| 62 | * @param <R> A type of the function's returned value. | |
| 63 | * @return A printable function. | |
| 64 | */ | |
| 65 | public static <T, R> Function<T, R> function(Supplier<String> formatter, Function<T, R> function) { | |
| 66 |
1
1. function : replaced return value with null for com/github/dakusui/pcond/forms/Printables::function → KILLED |
return PrintableFunctionFactory.function(formatter, function); |
| 67 | } | |
| 68 | } | |
Mutations | ||
| 27 |
1.1 |
|
| 39 |
1.1 |
|
| 53 |
1.1 |
|
| 66 |
1.1 |