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