| 1 | package pro.verron.officestamper.preset.resolvers.nulls; | |
| 2 | ||
| 3 | import org.jspecify.annotations.Nullable; | |
| 4 | import pro.verron.officestamper.api.DocxPart; | |
| 5 | import pro.verron.officestamper.api.Insert; | |
| 6 | import pro.verron.officestamper.api.ObjectResolver; | |
| 7 | ||
| 8 | import static pro.verron.officestamper.utils.wml.WmlFactory.newRun; | |
| 9 | ||
| 10 | /// The [Null2PlaceholderResolver] class is an implementation of the ObjectResolver interface. It provides a way to | |
| 11 | /// resolve null objects by not replacing their expression. | |
| 12 | /// | |
| 13 | /// @author Joseph Verron | |
| 14 | /// @version ${version} | |
| 15 | /// @since 1.6.7 | |
| 16 | public class Null2PlaceholderResolver | |
| 17 | implements ObjectResolver { | |
| 18 | ||
| 19 | private final String placeholderTemplate; | |
| 20 | ||
| 21 | /// Constructs a new [Null2PlaceholderResolver] with the specified placeholder template. | |
| 22 | /// | |
| 23 | /// @param template the template string to be used for formatting placeholders, where the expression will be | |
| 24 | /// inserted using [String#format()] | |
| 25 | public Null2PlaceholderResolver(String template) { | |
| 26 | this.placeholderTemplate = template; | |
| 27 | } | |
| 28 | ||
| 29 | @Override | |
| 30 | public Insert resolve(DocxPart part, String expression, @Nullable Object object) { | |
| 31 |
1
1. resolve : replaced return value with null for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::resolve → TIMED_OUT |
return new Insert(newRun(placeholderTemplate.formatted(expression))); |
| 32 | } | |
| 33 | ||
| 34 | @Override | |
| 35 | public boolean canResolve(@Nullable Object object) { | |
| 36 |
2
1. canResolve : negated conditional → TIMED_OUT 2. canResolve : replaced boolean return with true for pro/verron/officestamper/preset/resolvers/nulls/Null2PlaceholderResolver::canResolve → TIMED_OUT |
return object == null; |
| 37 | } | |
| 38 | } | |
Mutations | ||
| 31 |
1.1 |
|
| 36 |
1.1 2.2 |