ObjectTransformer.java

1
package com.github.dakusui.pcond.core.fluent.builtins;
2
3
import com.github.dakusui.pcond.core.fluent.AbstractObjectTransformer;
4
import com.github.dakusui.pcond.core.fluent.Transformer;
5
import com.github.dakusui.pcond.forms.Functions;
6
import com.github.dakusui.pcond.forms.Printables;
7
8
import java.util.List;
9
import java.util.function.Function;
10
import java.util.function.Predicate;
11
import java.util.function.Supplier;
12
13
import static com.github.dakusui.pcond.internals.InternalUtils.trivialIdentityFunction;
14
import static java.lang.String.format;
15
16
17
/**
18
 * This interface is used for object whose type doesn't have an explicit support.
19
 * Do not try to extend/implement this class to support your own class.
20
 */
21
public interface ObjectTransformer<
22
    T,
23
    E
24
    > extends
25
    AbstractObjectTransformer<
26
        ObjectTransformer<T, E>,
27
        ObjectChecker<T, E>,
28
        T,
29
        E> {
30
31
  @SuppressWarnings("unchecked")
32
  default ObjectTransformer<T, E> transform(Function<ObjectTransformer<T, E>, Predicate<E>> clause) {
33 2 1. lambda$transform$0 : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::lambda$transform$0 → NO_COVERAGE
2. transform : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::transform → NO_COVERAGE
    return this.addTransformAndCheckClause(tx -> clause.apply((ObjectTransformer<T, E>) tx));
34
  }
35
36
  /**
37
   * Lets the framework know the value to be checked is a `String`.
38
   * This method may throws an exception, if the value is not a `String`.
39
   *
40
   * @return A {@link StringTransformer<T>} object.
41
   */
42
  default StringTransformer<T> asString() {
43 1 1. asString : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asString → KILLED
    return toString(Functions.cast(String.class));
44
  }
45
46
  /**
47
   * Lets the framework know the value to be checked is a `Integer`.
48
   * This method may throws an exception, if the value is not a `Integer`.
49
   *
50
   * @return A {@link IntegerTransformer<T>} object.
51
   */
52
  default IntegerTransformer<T> asInteger() {
53 1 1. asInteger : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asInteger → KILLED
    return toInteger(Functions.cast(Integer.class));
54
  }
55
56
  /**
57
   * Lets the framework know the value to be checked is a `Long`.
58
   * This method may throws an exception, if the value is not a `Long`.
59
   *
60
   * @return A {@link LongTransformer<T>} object.
61
   */
62
  default LongTransformer<T> asLong() {
63 1 1. asLong : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asLong → KILLED
    return toLong(Functions.cast(Long.class));
64
  }
65
66
  /**
67
   * Lets the framework know the value to be checked is a `Short`.
68
   * This method may throws an exception, if the value is not a `Short`.
69
   *
70
   * @return A {@link ShortTransformer<T>} object.
71
   */
72
  default ShortTransformer<T> asShort() {
73 1 1. asShort : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asShort → KILLED
    return toShort(Functions.cast(Short.class));
74
  }
75
76
  /**
77
   * Lets the framework know the value to be checked is a `Double`.
78
   * This method may throws an exception, if the value is not a `Double`.
79
   *
80
   * @return A {@link DoubleTransformer<T>} object.
81
   */
82
  default DoubleTransformer<T> asDouble() {
83 1 1. asDouble : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asDouble → KILLED
    return toDouble(Functions.cast(Double.class));
84
  }
85
86
  /**
87
   * Lets the framework know the value to be checked is a `Float`.
88
   * This method may throws an exception, if the value is not a `Float`.
89
   *
90
   * @return A {@link FloatTransformer<T>} object.
91
   */
92
  default FloatTransformer<T> asFloat() {
93 1 1. asFloat : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asFloat → KILLED
    return toFloat(Functions.cast(Float.class));
94
  }
95
96
  /**
97
   * Lets the framework know the value to be checked is a `Boolean`.
98
   * This method may throws an exception, if the value is not a `Boolean`.
99
   *
100
   * @return A {@link BooleanTransformer<T>} object.
101
   */
102
  default BooleanTransformer<T> asBoolean() {
103
    /**
104
     * Lets the framework know the value to be checked is a `Boolean`.
105
     * This method may throws an exception, if the value is not a `Boolean`.
106
     *
107
     * @return A {@link BooleanTransformer<T>} object.
108
     */
109 1 1. asBoolean : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asBoolean → KILLED
    return toBoolean(Functions.cast(Boolean.class));
110
  }
111
112
  /**
113
   * Lets the framework know the value to be checked is a `List` of `EE`.
114
   * This method may throws an exception, if the value is not a `List`.
115
   *
116
   * @return A {@link ListTransformer<EE>} object.
117
   */
118
  @SuppressWarnings("unchecked")
119
  default <EE> ListTransformer<T, EE> asListOf(Class<EE> type) {
120 2 1. lambda$asListOf$1 : replaced return value with Collections.emptyList for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::lambda$asListOf$1 → NO_COVERAGE
2. asListOf : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asListOf → KILLED
    return toList(Printables.function(format("castTo[List<%s>]", type.getSimpleName()), v -> (List<EE>)v));
121
  }
122
123
  /**
124
   * Lets the framework know the value to be checked is a `List`.
125
   * This method may throws an exception, if the value is not a `List`.
126
   *
127
   * @return A {@link ListTransformer<T>} object.
128
   */
129
  @SuppressWarnings("unchecked")
130
  default <EE> ListTransformer<T, EE> asList() {
131 1 1. asList : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asList → KILLED
    return (ListTransformer<T, EE>) asListOf(Object.class);
132
  }
133
  
134
  static <E> ObjectTransformer<E, E> create(Supplier<E> value) {
135 1 1. create : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::create → KILLED
    return new Impl<>(value, trivialIdentityFunction());
136
  }
137
138
  class Impl<
139
      T,
140
      E> extends
141
      Transformer.Base<
142
          ObjectTransformer<T, E>,
143
          ObjectChecker<T, E>,
144
          T,
145
          E> implements
146
      ObjectTransformer<T, E> {
147
    public Impl(Supplier<T> rootValue, Function<T, E> root) {
148
      super(rootValue, root);
149
    }
150
151
    @Override
152
    protected ObjectChecker<T, E> toChecker(Function<T, E> transformFunction) {
153 1 1. toChecker : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer$Impl::toChecker → KILLED
      return new ObjectChecker.Impl<>(this::baseValue, transformFunction);
154
    }
155
156
    @Override
157
    protected ObjectTransformer<E, E> rebase() {
158 1 1. rebase : replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer$Impl::rebase → NO_COVERAGE
      return new ObjectTransformer.Impl<>(this::value, trivialIdentityFunction());
159
    }
160
161
  }
162
}

Mutations

33

1.1
Location : lambda$transform$0
Killed by : none
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::lambda$transform$0 → NO_COVERAGE

2.2
Location : transform
Killed by : none
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::transform → NO_COVERAGE

43

1.1
Location : asString
Killed by : com.github.dakusui.ut.valid8j.ut.styles.FluentStyleDbCTest$ForRequiresTest.requireValue_passing(com.github.dakusui.ut.valid8j.ut.styles.FluentStyleDbCTest$ForRequiresTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asString → KILLED

53

1.1
Location : asInteger
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asInteger → KILLED

63

1.1
Location : asLong
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asLong → KILLED

73

1.1
Location : asShort
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asShort → KILLED

83

1.1
Location : asDouble
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asDouble → KILLED

93

1.1
Location : asFloat
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asFloat → KILLED

109

1.1
Location : asBoolean
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asBoolean → KILLED

120

1.1
Location : asListOf
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asListOf → KILLED

2.2
Location : lambda$asListOf$1
Killed by : none
replaced return value with Collections.emptyList for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::lambda$asListOf$1 → NO_COVERAGE

131

1.1
Location : asList
Killed by : com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest.exerciseTestCase[28: Given:<"456">:When::Then:greaterThan(1), numbersOfExpectAndActualSummaries=>areEqual, numbersOfExpectAndActualSummariesWithDetails=>areEqual, numberOfExpectDetails=>greaterThan(1), numbersOfExpectAndActualDetails=>areEqual]>](com.github.dakusui.ut.valid8j.ut.styles.fluent.GeneralFluentTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::asList → KILLED

135

1.1
Location : create
Killed by : com.github.dakusui.ut.thincrest.ut.styles.FluentStyleTestAssertionTest$ForTestAssertionsTest.object_assertThatTest_passed(com.github.dakusui.ut.thincrest.ut.styles.FluentStyleTestAssertionTest$ForTestAssertionsTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer::create → KILLED

153

1.1
Location : toChecker
Killed by : com.github.dakusui.ut.thincrest.ut.styles.MoreFluentListTest.test_elementAt(com.github.dakusui.ut.thincrest.ut.styles.MoreFluentListTest)
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer$Impl::toChecker → KILLED

158

1.1
Location : rebase
Killed by : none
replaced return value with null for com/github/dakusui/pcond/core/fluent/builtins/ObjectTransformer$Impl::rebase → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.7.3