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 | import pro.verron.officestamper.api.OfficeStamperException; | |
8 | import pro.verron.officestamper.api.Placeholder; | |
9 | ||
10 | import static pro.verron.officestamper.utils.WmlFactory.newRun; | |
11 | ||
12 | /** | |
13 | * The {@link Null2PlaceholderResolver} class is an implementation of the ObjectResolver interface. | |
14 | * It provides a way to resolve null objects by not replacing their expression. | |
15 | * | |
16 | * @author Joseph Verron | |
17 | * @version ${version} | |
18 | * @since 1.6.7 | |
19 | */ | |
20 | public class Null2PlaceholderResolver | |
21 | implements ObjectResolver { | |
22 | ||
23 | /* package */ | |
24 | public Null2PlaceholderResolver() { | |
25 | //DO NOTHING | |
26 | } | |
27 | ||
28 | @Override | |
29 | public R resolve( | |
30 | DocxPart document, | |
31 | Placeholder placeholder, | |
32 | Object object | |
33 | ) { | |
34 |
1
1. resolve : replaced return value with null for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::resolve → KILLED |
return newRun(placeholder.expression()); |
35 | } | |
36 | ||
37 | @Override | |
38 | public boolean canResolve(@Nullable Object object) { | |
39 |
2
1. canResolve : replaced boolean return with true for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::canResolve → SURVIVED 2. canResolve : negated conditional → KILLED |
return object == null; |
40 | } | |
41 | ||
42 | @Override | |
43 | public R resolve( | |
44 | DocxPart document, | |
45 | String expression, | |
46 | Object object | |
47 | ) { | |
48 | throw new OfficeStamperException("Should not be called"); | |
49 | } | |
50 | } | |
Mutations | ||
34 |
1.1 |
|
39 |
1.1 2.2 |