Printables.java

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
Location : predicate
Killed by : com.github.dakusui.pcond.ut.PrintablePredicateTest$LeafPred.testHashCode(com.github.dakusui.pcond.ut.PrintablePredicateTest$LeafPred)
replaced return value with null for com/github/dakusui/pcond/forms/Printables::predicate → KILLED

39

1.1
Location : predicate
Killed by : com.github.dakusui.pcond.ut.InternalUtilsTest$ToEvaluableIfNecessaryTest.givenNonEvaluable$whenToEvaluableIfNecessary$thenConverted(com.github.dakusui.pcond.ut.InternalUtilsTest$ToEvaluableIfNecessaryTest)
replaced return value with null for com/github/dakusui/pcond/forms/Printables::predicate → KILLED

53

1.1
Location : function
Killed by : com.github.dakusui.pcond.ut.PrintablesTest$FunctionTest.givenFunctionReturnedByAndThen$whenToString$thenLooksGood(com.github.dakusui.pcond.ut.PrintablesTest$FunctionTest)
replaced return value with null for com/github/dakusui/pcond/forms/Printables::function → KILLED

66

1.1
Location : function
Killed by : com.github.dakusui.pcond.experimentals.TestAssertionsCurriedFunctionsTest.parameterizedFunctionTest(com.github.dakusui.pcond.experimentals.TestAssertionsCurriedFunctionsTest)
replaced return value with null for com/github/dakusui/pcond/forms/Printables::function → KILLED

Active mutators

Tests examined


Report generated by PIT 1.7.3