1 | package com.github.valid8j.pcond.core.fluent; | |
2 | ||
3 | import com.github.valid8j.pcond.forms.Functions; | |
4 | import com.github.valid8j.pcond.core.fluent.builtins.*; | |
5 | import com.github.valid8j.pcond.core.refl.MethodQuery; | |
6 | ||
7 | import java.util.List; | |
8 | import java.util.Objects; | |
9 | import java.util.function.Function; | |
10 | import java.util.stream.Stream; | |
11 | ||
12 | import static com.github.valid8j.pcond.forms.Functions.call; | |
13 | import static java.util.Objects.requireNonNull; | |
14 | ||
15 | /** | |
16 | * | |
17 | * @param <TX> The type of the extending class itself. | |
18 | * @param <V> A type of checker produced by this transformer. | |
19 | * @param <T> The type of the target value of the instance of this interface. | |
20 | * @param <R> The type of the target value of the checker instance `V` | |
21 | */ | |
22 | public interface AbstractObjectTransformer< | |
23 | TX extends AbstractObjectTransformer<TX, V, T, R>, | |
24 | V extends AbstractObjectChecker<V, T, R>, | |
25 | T, | |
26 | R | |
27 | > extends | |
28 | Transformer<TX, V, T, R> { | |
29 | ||
30 | /** | |
31 | * Corresponds to {@code toString()} method. | |
32 | * | |
33 | * @return this object the method appended. | |
34 | */ | |
35 | @SuppressWarnings("unchecked") | |
36 | default StringTransformer<String> stringify() { | |
37 |
1
1. stringify : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::stringify → KILLED |
return (StringTransformer<String>) this.toString(Functions.stringify()); |
38 | } | |
39 | ||
40 | default <E> ObjectTransformer<T, E> function(Function<R, E> function) { | |
41 |
1
1. function : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::function → KILLED |
return this.toObject(Objects.requireNonNull(function)); |
42 | } | |
43 | ||
44 | default <E> ObjectTransformer<T, E> invoke(String methodName, Object... args) { | |
45 |
1
1. invoke : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::invoke → KILLED |
return this.function(Functions.call(MethodQuery.instanceMethod(Functions.parameter(), methodName, args))); |
46 | } | |
47 | ||
48 | default <E> ObjectTransformer<T, E> invokeStatic(Class<?> klass, String methodName, Object... args) { | |
49 |
1
1. invokeStatic : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::invokeStatic → KILLED |
return this.function(Functions.call(MethodQuery.classMethod(klass, methodName, args))); |
50 | } | |
51 | ||
52 | /** | |
53 | * Applies `f`, which is expected to throw an exception object of class `exceptionClass`, to the target value of this transformer object. | |
54 | * In case no exception is thrown, or a different type of exception is thrown, an exception will be thrown. | |
55 | * But its type is not specified. | |
56 | * | |
57 | * @param exceptionClass A class of exception object of the exception to be thrown by `f`. | |
58 | * @param f A function that is expected to throw an exception object of `exceptionClass`. | |
59 | * @return A {@link ThrowableTransformer} instance constructed for the thrown exception by `f`. | |
60 | * @param <O> An exception class to be thrown by `f`. | |
61 | * @see Functions#expectingException(Class, Function) | |
62 | */ | |
63 | default <O extends Throwable> ThrowableTransformer<T, O> expectException(Class<O> exceptionClass, Function<? super R, ?> f) { | |
64 | requireNonNull(exceptionClass); | |
65 |
1
1. expectException : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::expectException → KILLED |
return this.toThrowable(Functions.expectingException(exceptionClass, f)); |
66 | } | |
67 | ||
68 | /** | |
69 | * Mainly used for internal purposes | |
70 | * @return Another transformer objecct. | |
71 | * @param <E> | |
72 | */ | |
73 | @SuppressWarnings("unchecked") | |
74 | default <E> ObjectTransformer<T, E> asObject() { | |
75 |
1
1. asObject : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::asObject → KILLED |
return (ObjectTransformer<T, E>)this.toObject(Functions.identity()); |
76 | } | |
77 | ||
78 | /** | |
79 | * Applies a given `function` to the currently targeted value and returns a new `ObjectTransformer` whose target value is the returned value from the `function`. | |
80 | * | |
81 | * @param function A function to be applied to the target value. | |
82 | * @return A new {@link ObjectTransformer} which targets the result of the `function`. | |
83 | * @param <E> The type of the returned value of the `function`. | |
84 | */ | |
85 | default <E> ObjectTransformer<T, E> toObject(Function<R, E> function) { | |
86 |
1
1. toObject : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toObject → KILLED |
return this.transformValueWith(function, ObjectTransformer.Impl::new); |
87 | } | |
88 | ||
89 | default BooleanTransformer<T> toBoolean(Function<? super R, Boolean> function) { | |
90 |
1
1. toBoolean : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toBoolean → KILLED |
return this.transformValueWith(function, BooleanTransformer.Impl::new); |
91 | } | |
92 | ||
93 | default IntegerTransformer<T> toInteger(Function<? super R, Integer> function) { | |
94 |
1
1. toInteger : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toInteger → KILLED |
return this.transformValueWith(function, IntegerTransformer.Impl::new); |
95 | } | |
96 | ||
97 | default LongTransformer<T> toLong(Function<? super R, Long> function) { | |
98 |
1
1. toLong : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toLong → KILLED |
return this.transformValueWith(function, LongTransformer.Impl::new); |
99 | } | |
100 | ||
101 | default ShortTransformer<T> toShort(Function<? super R, Short> function) { | |
102 |
1
1. toShort : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toShort → KILLED |
return this.transformValueWith(function, ShortTransformer.Impl::new); |
103 | } | |
104 | ||
105 | default DoubleTransformer<T> toDouble(Function<? super R, Double> function) { | |
106 |
1
1. toDouble : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toDouble → KILLED |
return this.transformValueWith(function, DoubleTransformer.Impl::new); |
107 | } | |
108 | ||
109 | default FloatTransformer<T> toFloat(Function<? super R, Float> function) { | |
110 |
1
1. toFloat : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toFloat → KILLED |
return this.transformValueWith(function, FloatTransformer.Impl::new); |
111 | } | |
112 | ||
113 | default StringTransformer<T> toString(Function<? super R, String> function) { | |
114 |
1
1. toString : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toString → KILLED |
return this.transformValueWith(function, StringTransformer.Impl::new); |
115 | } | |
116 | ||
117 | default <E> ListTransformer<T, E> toList(Function<? super R, List<E>> function) { | |
118 |
1
1. toList : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toList → KILLED |
return this.transformValueWith(function, ListTransformer.Impl::new); |
119 | } | |
120 | ||
121 | default <E> StreamTransformer<T, E> toStream(Function<? super R, Stream<E>> function) { | |
122 |
1
1. toStream : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toStream → KILLED |
return this.transformValueWith(function, StreamTransformer.Impl::new); |
123 | } | |
124 | ||
125 | default <E extends Throwable> ThrowableTransformer<T, E> toThrowable(Function<? super R, E> function) { | |
126 |
1
1. toThrowable : replaced return value with null for com/github/valid8j/pcond/core/fluent/AbstractObjectTransformer::toThrowable → KILLED |
return this.transformValueWith(function, ThrowableTransformer.Impl::new); |
127 | ||
128 | } | |
129 | } | |
Mutations | ||
37 |
1.1 |
|
41 |
1.1 |
|
45 |
1.1 |
|
49 |
1.1 |
|
65 |
1.1 |
|
75 |
1.1 |
|
86 |
1.1 |
|
90 |
1.1 |
|
94 |
1.1 |
|
98 |
1.1 |
|
102 |
1.1 |
|
106 |
1.1 |
|
110 |
1.1 |
|
114 |
1.1 |
|
118 |
1.1 |
|
122 |
1.1 |
|
126 |
1.1 |