1 | package pro.verron.officestamper.preset.resolvers.nulls; | |
2 | ||
3 | import org.docx4j.wml.R; | |
4 | import org.springframework.lang.Nullable; | |
5 | import pro.verron.officestamper.api.DocxPart; | |
6 | import pro.verron.officestamper.api.ObjectResolver; | |
7 | ||
8 | import static pro.verron.officestamper.utils.WmlFactory.newRun; | |
9 | ||
10 | /** | |
11 | * The Null2DefaultResolver class is an implementation of the | |
12 | * {@link ObjectResolver} interface | |
13 | * that resolves null objects by creating a run with a default text value. | |
14 | * | |
15 | * @author Joseph Verron | |
16 | * @version ${version} | |
17 | * @since 1.6.7 | |
18 | */ | |
19 | public record Null2DefaultResolver(String text) | |
20 | implements ObjectResolver { | |
21 | ||
22 | /** | |
23 | * The Null2DefaultResolver class is an implementation of the ObjectResolver interface | |
24 | * that resolves null objects by creating a run with a default text value. | |
25 | * | |
26 | * @param text The default text value to be used when the resolved object is null | |
27 | */ | |
28 | /* package */ | |
29 | public Null2DefaultResolver { | |
30 | } | |
31 | ||
32 | @Override | |
33 | public boolean canResolve(@Nullable Object object) { | |
34 |
2
1. canResolve : negated conditional → KILLED 2. canResolve : replaced boolean return with true for pro/verron/officestamper/preset/resolvers/nulls/Null2DefaultResolver::canResolve → KILLED |
return object == null; |
35 | } | |
36 | ||
37 | @Override | |
38 | public R resolve( | |
39 | DocxPart document, | |
40 | String expression, | |
41 | Object object | |
42 | ) { | |
43 |
1
1. resolve : replaced return value with null for pro/verron/officestamper/preset/resolvers/nulls/Null2DefaultResolver::resolve → KILLED |
return newRun(text); |
44 | } | |
45 | ||
46 | /** | |
47 | * Retrieves the default value of the {@link Null2DefaultResolver} object. | |
48 | * | |
49 | * @return the default value of the {@link Null2DefaultResolver} object as a String | |
50 | */ | |
51 | public String defaultValue() { | |
52 |
1
1. defaultValue : replaced return value with "" for pro/verron/officestamper/preset/resolvers/nulls/Null2DefaultResolver::defaultValue → NO_COVERAGE |
return text; |
53 | } | |
54 | } | |
Mutations | ||
34 |
1.1 2.2 |
|
43 |
1.1 |
|
52 |
1.1 |