DocxStamperConfiguration.java

1
package pro.verron.officestamper.core;
2
3
4
import org.springframework.expression.EvaluationContext;
5
import org.springframework.expression.spel.SpelParserConfiguration;
6
import org.springframework.lang.NonNull;
7
import pro.verron.officestamper.api.*;
8
import pro.verron.officestamper.api.CustomFunction.NeedsBiFunctionImpl;
9
import pro.verron.officestamper.api.CustomFunction.NeedsFunctionImpl;
10
import pro.verron.officestamper.api.CustomFunction.NeedsTriFunctionImpl;
11
import pro.verron.officestamper.core.functions.BiFunctionBuilder;
12
import pro.verron.officestamper.core.functions.FunctionBuilder;
13
import pro.verron.officestamper.core.functions.TriFunctionBuilder;
14
import pro.verron.officestamper.preset.EvaluationContextConfigurers;
15
import pro.verron.officestamper.preset.ExceptionResolvers;
16
17
import java.util.ArrayList;
18
import java.util.HashMap;
19
import java.util.List;
20
import java.util.Map;
21
import java.util.function.Function;
22
import java.util.function.Supplier;
23
24
/// The [DocxStamperConfiguration] class represents the configuration for the [DocxStamper] class.
25
/// It provides methods to customize the behavior of the stamper.
26
///
27
/// @author Joseph Verron
28
/// @author Tom Hombergs
29
/// @version ${version}
30
/// @since 1.0.3
31
public class DocxStamperConfiguration
32
        implements OfficeStamperConfiguration {
33
    private final Map<Class<?>, Function<ParagraphPlaceholderReplacer, CommentProcessor>> commentProcessors;
34
    private final List<ObjectResolver> resolvers;
35
    private final Map<Class<?>, Object> expressionFunctions;
36
    private final List<PreProcessor> preprocessors;
37
    private final List<PostProcessor> postprocessors;
38
    private final List<CustomFunction> functions;
39
    private String lineBreakPlaceholder;
40
    private EvaluationContextConfigurer evaluationContextConfigurer;
41
    private boolean failOnUnresolvedExpression;
42
    private boolean leaveEmptyOnExpressionError;
43
    private boolean replaceUnresolvedExpressions;
44
    private String unresolvedExpressionsDefaultValue;
45
    private SpelParserConfiguration spelParserConfiguration;
46
    private ExceptionResolver exceptionResolver;
47
48
    /// Constructs a new instance of the `DocxStamperConfiguration` class
49
    /// and initializes its default configuration settings.
50
    /// This constructor sets up internal structures and default behaviors
51
    /// for managing document stamping configurations, including:
52
    /// - Initializing collections for processors, resolvers, and functions.
53
    /// - Setting default values for expression handling and evaluation.
54
    /// - Creating and configuring a default `SpelParserConfiguration`.
55
    /// - Establishing resolvers and exception handling strategies.
56
    public DocxStamperConfiguration() {
57
        commentProcessors = new HashMap<>();
58
        resolvers = new ArrayList<>();
59
        expressionFunctions = new HashMap<>();
60
        preprocessors = new ArrayList<>();
61
        postprocessors = new ArrayList<>();
62
        functions = new ArrayList<>();
63
        evaluationContextConfigurer = EvaluationContextConfigurers.defaultConfigurer();
64
        lineBreakPlaceholder = "\n";
65
        failOnUnresolvedExpression = true;
66
        leaveEmptyOnExpressionError = false;
67
        replaceUnresolvedExpressions = false;
68
        unresolvedExpressionsDefaultValue = null;
69
        spelParserConfiguration = new SpelParserConfiguration();
70
        exceptionResolver = computeExceptionResolver();
71
    }
72
73
    private ExceptionResolver computeExceptionResolver() {
74 2 1. computeExceptionResolver : negated conditional → KILLED
2. computeExceptionResolver : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::computeExceptionResolver → KILLED
        if (failOnUnresolvedExpression) return ExceptionResolvers.throwing();
75 2 1. computeExceptionResolver : negated conditional → NO_COVERAGE
2. computeExceptionResolver : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::computeExceptionResolver → NO_COVERAGE
        if (replaceWithDefaultOnError()) return ExceptionResolvers.defaulting(replacementDefault());
76 1 1. computeExceptionResolver : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::computeExceptionResolver → NO_COVERAGE
        return ExceptionResolvers.passing();
77
    }
78
79
    private boolean replaceWithDefaultOnError() {
80 3 1. replaceWithDefaultOnError : negated conditional → NO_COVERAGE
2. replaceWithDefaultOnError : replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::replaceWithDefaultOnError → NO_COVERAGE
3. replaceWithDefaultOnError : negated conditional → NO_COVERAGE
        return isLeaveEmptyOnExpressionError() || isReplaceUnresolvedExpressions();
81
    }
82
83
    private String replacementDefault() {
84 2 1. replacementDefault : replaced return value with "" for pro/verron/officestamper/core/DocxStamperConfiguration::replacementDefault → NO_COVERAGE
2. replacementDefault : negated conditional → NO_COVERAGE
        return isLeaveEmptyOnExpressionError() ? "" : getUnresolvedExpressionsDefaultValue();
85
    }
86
87
    /// Resets all processors in the configuration.
88
    public void resetCommentProcessors() {
89 1 1. resetCommentProcessors : removed call to java/util/Map::clear → SURVIVED
        this.commentProcessors.clear();
90
    }
91
92
    /// Resets all resolvers in the configuration.
93
    public void resetResolvers() {
94 1 1. resetResolvers : removed call to java/util/List::clear → SURVIVED
        this.resolvers.clear();
95
    }
96
97
    /// Determines whether the system should fail when an unresolved expression is encountered.
98
    ///
99
    /// @deprecated use [#getExceptionResolver()] instead
100
    ///
101
    /// @return true if the system is configured to fail on unresolved expressions, false otherwise
102
    @Deprecated(since = "2.5", forRemoval = true)
103
    @Override
104
    public boolean isFailOnUnresolvedExpression() {
105 2 1. isFailOnUnresolvedExpression : replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::isFailOnUnresolvedExpression → NO_COVERAGE
2. isFailOnUnresolvedExpression : replaced boolean return with false for pro/verron/officestamper/core/DocxStamperConfiguration::isFailOnUnresolvedExpression → NO_COVERAGE
        return failOnUnresolvedExpression;
106
    }
107
108
    /// If true, stamper throws an [OfficeStamperException] if an expression within the document can’t be resolved.
109
    /// Set to `TRUE` by default.
110
    ///
111
    /// @param failOnUnresolvedExpression a boolean
112
    ///
113
    /// @deprecated use [#setExceptionResolver(ExceptionResolver)] instead
114
    ///
115
    /// @return the same [DocxStamperConfiguration] object
116
    @Deprecated(since = "2.5", forRemoval = true)
117
    @Override
118
    public DocxStamperConfiguration setFailOnUnresolvedExpression(boolean failOnUnresolvedExpression) {
119
        this.failOnUnresolvedExpression = failOnUnresolvedExpression;
120
        this.exceptionResolver = computeExceptionResolver();
121 1 1. setFailOnUnresolvedExpression : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setFailOnUnresolvedExpression → NO_COVERAGE
        return this;
122
    }
123
124
    /// Determines whether to leave the value empty when there is an error in expression evaluation.
125
    ///
126
    /// @return true if the value should be left empty on expression evaluation errors; false otherwise.
127
    @Override
128
    public boolean isLeaveEmptyOnExpressionError() {
129 2 1. isLeaveEmptyOnExpressionError : replaced boolean return with false for pro/verron/officestamper/core/DocxStamperConfiguration::isLeaveEmptyOnExpressionError → NO_COVERAGE
2. isLeaveEmptyOnExpressionError : replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::isLeaveEmptyOnExpressionError → NO_COVERAGE
        return leaveEmptyOnExpressionError;
130
    }
131
132
    /// Determines whether unresolved expressions should be replaced.
133
    ///
134
    /// @return true if unresolved expressions are set to be replaced, false otherwise.
135
    @Override
136
    public boolean isReplaceUnresolvedExpressions() {
137 2 1. isReplaceUnresolvedExpressions : replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::isReplaceUnresolvedExpressions → NO_COVERAGE
2. isReplaceUnresolvedExpressions : replaced boolean return with false for pro/verron/officestamper/core/DocxStamperConfiguration::isReplaceUnresolvedExpressions → NO_COVERAGE
        return replaceUnresolvedExpressions;
138
    }
139
140
    /// Retrieves the default value used for unresolved expressions.
141
    ///
142
    /// @return the default value assigned to unresolved expressions as a String
143
    @Override
144
    public String getUnresolvedExpressionsDefaultValue() {
145 1 1. getUnresolvedExpressionsDefaultValue : replaced return value with "" for pro/verron/officestamper/core/DocxStamperConfiguration::getUnresolvedExpressionsDefaultValue → NO_COVERAGE
        return unresolvedExpressionsDefaultValue;
146
    }
147
148
    /// Default value to use for expressions that doesn't resolve.
149
    ///
150
    /// @param unresolvedExpressionsDefaultValue value to use instead for expression that doesn't resolve
151
    ///
152
    /// @deprecated use [#getExceptionResolver()] instead
153
    ///
154
    /// @return a [DocxStamperConfiguration] object
155
    ///
156
    /// @see DocxStamperConfiguration#replaceUnresolvedExpressions
157
    @Deprecated(since = "2.5", forRemoval = true)
158
    @Override
159
    public DocxStamperConfiguration unresolvedExpressionsDefaultValue(String unresolvedExpressionsDefaultValue) {
160
        this.unresolvedExpressionsDefaultValue = unresolvedExpressionsDefaultValue;
161
        this.exceptionResolver = computeExceptionResolver();
162 1 1. unresolvedExpressionsDefaultValue : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::unresolvedExpressionsDefaultValue → NO_COVERAGE
        return this;
163
    }
164
165
    /// Indicates if a default value should replace expressions that don't resolve.
166
    ///
167
    /// @param replaceUnresolvedExpressions true to replace expression with resolved value `null` false to leave the
168
    /// expression as is.
169
    ///
170
    /// @deprecated use [#setExceptionResolver(ExceptionResolver)] instead
171
    ///
172
    /// @return a [DocxStamperConfiguration] object
173
    @Deprecated(since = "2.5", forRemoval = true)
174
    @Override
175
    public DocxStamperConfiguration replaceUnresolvedExpressions(boolean replaceUnresolvedExpressions) {
176
        this.replaceUnresolvedExpressions = replaceUnresolvedExpressions;
177
        this.exceptionResolver = computeExceptionResolver();
178 1 1. replaceUnresolvedExpressions : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::replaceUnresolvedExpressions → NO_COVERAGE
        return this;
179
    }
180
181
    /// Indicate if expressions failing during evaluation needs removal.
182
    ///
183
    /// @param leaveEmpty true to replace expressions with empty string when an error occurs during evaluation.
184
    ///
185
    /// @deprecated use [#setExceptionResolver(ExceptionResolver)] instead
186
    ///
187
    /// @return a [DocxStamperConfiguration] object
188
    @Deprecated(since = "2.5", forRemoval = true)
189
    @Override
190
    public DocxStamperConfiguration leaveEmptyOnExpressionError(boolean leaveEmpty) {
191
        this.leaveEmptyOnExpressionError = leaveEmpty;
192
        this.exceptionResolver = computeExceptionResolver();
193 1 1. leaveEmptyOnExpressionError : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::leaveEmptyOnExpressionError → NO_COVERAGE
        return this;
194
    }
195
196
    /// Exposes all methods of a given interface to the expression language.
197
    ///
198
    /// @param interfaceClass the interface holding methods to expose in the expression language.
199
    /// @param implementation the implementation to call to evaluate invocations of those methods. Must implement the
200
    ///
201
    ///                                             mentioned interface.
202
    ///
203
    /// @return a [DocxStamperConfiguration] object
204
    @Override
205
    public DocxStamperConfiguration exposeInterfaceToExpressionLanguage(
206
            Class<?> interfaceClass,
207
            Object implementation
208
    ) {
209
        this.expressionFunctions.put(interfaceClass, implementation);
210 1 1. exposeInterfaceToExpressionLanguage : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::exposeInterfaceToExpressionLanguage → KILLED
        return this;
211
    }
212
213
    /// Registers the specified ICommentProcessor as an implementation of the specified interface.
214
    ///
215
    /// @param interfaceClass          the interface, implemented by the commentProcessor.
216
    /// @param commentProcessorFactory the commentProcessor factory generating instances of the specified interface.
217
    ///
218
    /// @return a [DocxStamperConfiguration] object
219
    @Override
220
    public DocxStamperConfiguration addCommentProcessor(
221
            Class<?> interfaceClass,
222
            Function<ParagraphPlaceholderReplacer, CommentProcessor> commentProcessorFactory
223
    ) {
224
        this.commentProcessors.put(interfaceClass, commentProcessorFactory);
225 1 1. addCommentProcessor : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCommentProcessor → KILLED
        return this;
226
    }
227
228
    /// Adds a preprocessor to the configuration.
229
    ///
230
    /// @param preprocessor the preprocessor to add.
231
    @Override
232
    public void addPreprocessor(PreProcessor preprocessor) {
233
        preprocessors.add(preprocessor);
234
    }
235
236
237
    /// Retrieves the placeholder string used for line breaks.
238
    ///
239
    /// @return the line break placeholder as a string
240
    @Override
241
    public String getLineBreakPlaceholder() {
242 1 1. getLineBreakPlaceholder : replaced return value with "" for pro/verron/officestamper/core/DocxStamperConfiguration::getLineBreakPlaceholder → KILLED
        return lineBreakPlaceholder;
243
    }
244
245
    /// String to replace with a line break when stamping a document.
246
    /// By default, `\\n` is the placeholder.
247
    ///
248
    /// @param lineBreakPlaceholder string to replace with line breaks during stamping.
249
    ///
250
    /// @return the configuration object for chaining.
251
    @Override
252
    public DocxStamperConfiguration setLineBreakPlaceholder(@NonNull String lineBreakPlaceholder) {
253
        this.lineBreakPlaceholder = lineBreakPlaceholder;
254 1 1. setLineBreakPlaceholder : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setLineBreakPlaceholder → KILLED
        return this;
255
    }
256
257
    /// Retrieves the configured EvaluationContextConfigurer instance.
258
    ///
259
    /// @return an instance of EvaluationContextConfigurer used for configuring evaluation contexts
260
    @Override
261
    public EvaluationContextConfigurer getEvaluationContextConfigurer() {
262 1 1. getEvaluationContextConfigurer : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::getEvaluationContextConfigurer → KILLED
        return evaluationContextConfigurer;
263
    }
264
265
    /// Provides an [EvaluationContextConfigurer] which may change the configuration of a Spring
266
    /// [EvaluationContext] used for evaluating expressions in comments and text.
267
    ///
268
    /// @param evaluationContextConfigurer the configurer to use.
269
    ///
270
    /// @return the configuration object for chaining.
271
    @Override
272
    public DocxStamperConfiguration setEvaluationContextConfigurer(
273
            EvaluationContextConfigurer evaluationContextConfigurer
274
    ) {
275
        this.evaluationContextConfigurer = evaluationContextConfigurer;
276 1 1. setEvaluationContextConfigurer : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setEvaluationContextConfigurer → KILLED
        return this;
277
    }
278
279
    @Override
280
    public SpelParserConfiguration getSpelParserConfiguration() {
281 1 1. getSpelParserConfiguration : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::getSpelParserConfiguration → KILLED
        return spelParserConfiguration;
282
    }
283
284
    /// Sets the [SpelParserConfiguration] used for expression parsing.
285
    /// Note that this configuration is the same for all expressions in the document, including expressions in comments.
286
    ///
287
    /// @param spelParserConfiguration the configuration to use.
288
    ///
289
    /// @return the configuration object for chaining.
290
    @Override
291
    public DocxStamperConfiguration setSpelParserConfiguration(
292
            SpelParserConfiguration spelParserConfiguration
293
    ) {
294
        this.spelParserConfiguration = spelParserConfiguration;
295 1 1. setSpelParserConfiguration : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setSpelParserConfiguration → KILLED
        return this;
296
    }
297
298
    /// Retrieves the mapping of expression function classes to their corresponding function instances.
299
    ///
300
    /// @return a map where the keys are classes representing the function types and the values are the function
301
    /// instances.
302
    @Override
303
    public Map<Class<?>, Object> getExpressionFunctions() {
304 1 1. getExpressionFunctions : replaced return value with Collections.emptyMap for pro/verron/officestamper/core/DocxStamperConfiguration::getExpressionFunctions → KILLED
        return expressionFunctions;
305
    }
306
307
    /// Retrieves the map of comment processors associated with specific classes.
308
    ///
309
    /// @return a map where the key is the class associated with a specific type of placeholder
310
    ///         and the value is a function that creates a CommentProcessor for that placeholder.
311
    @Override
312
    public Map<Class<?>, Function<ParagraphPlaceholderReplacer, CommentProcessor>> getCommentProcessors() {
313 1 1. getCommentProcessors : replaced return value with Collections.emptyMap for pro/verron/officestamper/core/DocxStamperConfiguration::getCommentProcessors → KILLED
        return commentProcessors;
314
    }
315
316
    /// Retrieves the list of preprocessors.
317
    ///
318
    /// @return a list of PreProcessor objects.
319
    @Override
320
    public List<PreProcessor> getPreprocessors() {
321 1 1. getPreprocessors : replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::getPreprocessors → KILLED
        return preprocessors;
322
    }
323
324
    /// Retrieves the list of object resolvers.
325
    ///
326
    /// @return a list of `ObjectResolver` instances.
327
    @Override
328
    public List<ObjectResolver> getResolvers() {
329 1 1. getResolvers : replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::getResolvers → KILLED
        return resolvers;
330
    }
331
332
    /// Sets resolvers for resolving objects in the DocxStamperConfiguration.
333
    ///
334
    /// This method is the evolution of the method `addTypeResolver`,
335
    /// and the order in which the resolvers are ordered is determinant - the first resolvers
336
    /// in the list will be tried first. If a fallback resolver is desired, it should be placed last in the list.
337
    ///
338
    /// @param resolvers The list of ObjectResolvers to be set.
339
    ///
340
    /// @return the configuration object for chaining.
341
    @Override
342
    public DocxStamperConfiguration setResolvers(List<ObjectResolver> resolvers) {
343 1 1. setResolvers : removed call to java/util/List::clear → SURVIVED
        this.resolvers.clear();
344
        this.resolvers.addAll(resolvers);
345 1 1. setResolvers : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setResolvers → SURVIVED
        return this;
346
    }
347
348
    /// Adds a resolver to the list of resolvers in the `DocxStamperConfiguration` object.
349
    /// Resolvers are used to resolve objects during the stamping process.
350
    ///
351
    /// @param resolver The resolver to be added. This resolver should implement the `ObjectResolver` interface.
352
    ///
353
    /// @return The modified `DocxStamperConfiguration` object, with the resolver added to the beginning of the
354
    /// resolver list.
355
    @Override
356
    public DocxStamperConfiguration addResolver(ObjectResolver resolver) {
357 1 1. addResolver : removed call to java/util/List::addFirst → KILLED
        resolvers.addFirst(resolver);
358 1 1. addResolver : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addResolver → KILLED
        return this;
359
    }
360
361
    /// Retrieves the exception resolver.
362
    ///
363
    /// @return the current instance of ExceptionResolver.
364
    @Override
365
    public ExceptionResolver getExceptionResolver() {
366 1 1. getExceptionResolver : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::getExceptionResolver → KILLED
        return exceptionResolver;
367
    }
368
369
    /// Configures the exception resolver for the DocxStamperConfiguration.
370
    ///
371
    /// @param exceptionResolver the ExceptionResolver to handle exceptions during processing
372
    ///
373
    /// @return the current instance of DocxStamperConfiguration
374
    @Override
375
    public DocxStamperConfiguration setExceptionResolver(ExceptionResolver exceptionResolver) {
376
        this.exceptionResolver = exceptionResolver;
377 1 1. setExceptionResolver : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setExceptionResolver → KILLED
        return this;
378
    }
379
380
    /// Retrieves a list of custom functions.
381
    ///
382
    /// @return a List containing CustomFunction objects.
383
    @Override
384
    public List<CustomFunction> customFunctions() {
385 1 1. customFunctions : replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::customFunctions → KILLED
        return functions;
386
    }
387
388
    /// Adds a custom function to the system, allowing integration of user-defined functionality.
389
    ///
390
    /// @param name           The name of the custom function being added.
391
    ///                       This is used as the identifier for the function and must be unique
392
    ///                       across all defined functions.
393
    /// @param implementation A Supplier functional interface that provides the implementation of the custom function.
394
    ///                       When the function is called, the supplier's get method will be executed to return the
395
    ///                       result of the function.
396
    @Override
397
    public void addCustomFunction(String name, Supplier<?> implementation) {
398 2 1. lambda$addCustomFunction$0 : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::lambda$addCustomFunction$0 → KILLED
2. addCustomFunction : removed call to pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED
        this.addCustomFunction(new CustomFunction(name, List.of(), args -> implementation.get()));
399
    }
400
401
    /// Adds a custom function to the list of functions.
402
    ///
403
    /// @param function the CustomFunction object to be added
404
    public void addCustomFunction(CustomFunction function) {
405
        this.functions.add(function);
406
    }
407
408
    /// Adds a custom function to the context with the specified name and type.
409
    ///
410
    /// @param name   the name of the custom function
411
    /// @param class0 the class type of the custom function
412
    /// @param <T> the type of the input parameter
413
    /// @return an instance of NeedsFunctionImpl configured with the custom function
414
    @Override
415
    public <T> NeedsFunctionImpl<T> addCustomFunction(String name, Class<T> class0) {
416 1 1. addCustomFunction : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED
        return new FunctionBuilder<>(this, name, class0);
417
    }
418
419
    /// Adds a custom function with the specified name and input types.
420
    ///
421
    /// @param name the name of the custom function to be added
422
    /// @param class0 the class type of the first input parameter of the custom function
423
    /// @param class1 the class type of the second input parameter of the custom function
424
    /// @param <T> the type of the first input parameter
425
    /// @param <U> the type of the second input parameter
426
    /// @return an instance of NeedsBiFunctionImpl for further configuration or usage of the custom function
427
    @Override
428
    public <T, U> NeedsBiFunctionImpl<T, U> addCustomFunction(String name, Class<T> class0, Class<U> class1) {
429 1 1. addCustomFunction : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED
        return new BiFunctionBuilder<>(this, name, class0, class1);
430
    }
431
432
    /// Adds a custom function to the current context by defining its name and the classes
433
    /// associated with its argument types.
434
    ///
435
    /// @param name   the name to assign to the custom function
436
    /// @param class0 the class of the first argument type
437
    /// @param class1 the class of the second argument type
438
    /// @param class2 the class of the third argument type
439
    /// @param <T>    the type of the first argument
440
    /// @param <U>    the type of the second argument
441
    /// @param <V>    the type of the third argument
442
    ///
443
    /// @return an instance of NeedsTriFunctionImpl indicating the custom function implementation and usage context
444
    @Override
445
    public <T, U, V> NeedsTriFunctionImpl<T, U, V> addCustomFunction(
446
            String name,
447
            Class<T> class0,
448
            Class<U> class1,
449
            Class<V> class2
450
    ) {
451 1 1. addCustomFunction : replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED
        return new TriFunctionBuilder<>(this, name, class0, class1, class2);
452
    }
453
454
    /// Retrieves the list of postprocessors.
455
    ///
456
    /// @return a List of PostProcessor objects.
457
    @Override
458
    public List<PostProcessor> getPostprocessors() {
459 1 1. getPostprocessors : replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::getPostprocessors → KILLED
        return postprocessors;
460
    }
461
462
    /// Adds a given postprocessor to the list of postprocessors.
463
    ///
464
    /// @param postprocessor the PostProcessor instance to be added
465
    @Override
466
    public void addPostprocessor(PostProcessor postprocessor) {
467
        postprocessors.add(postprocessor);
468
    }
469
}

Mutations

74

1.1
Location : computeExceptionResolver
Killed by : pro.verron.officestamper.test.SpelInjectionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInjectionTest]/[test-template:spelInjectionTest(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

2.2
Location : computeExceptionResolver
Killed by : pro.verron.officestamper.test.SpelInjectionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.SpelInjectionTest]/[test-template:spelInjectionTest(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#1]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::computeExceptionResolver → KILLED

75

1.1
Location : computeExceptionResolver
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : computeExceptionResolver
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::computeExceptionResolver → NO_COVERAGE

76

1.1
Location : computeExceptionResolver
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::computeExceptionResolver → NO_COVERAGE

80

1.1
Location : replaceWithDefaultOnError
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : replaceWithDefaultOnError
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::replaceWithDefaultOnError → NO_COVERAGE

3.3
Location : replaceWithDefaultOnError
Killed by : none
negated conditional → NO_COVERAGE

84

1.1
Location : replacementDefault
Killed by : none
replaced return value with "" for pro/verron/officestamper/core/DocxStamperConfiguration::replacementDefault → NO_COVERAGE

2.2
Location : replacementDefault
Killed by : none
negated conditional → NO_COVERAGE

89

1.1
Location : resetCommentProcessors
Killed by : none
removed call to java/util/Map::clear → SURVIVED
Covering tests

94

1.1
Location : resetResolvers
Killed by : none
removed call to java/util/List::clear → SURVIVED
Covering tests

105

1.1
Location : isFailOnUnresolvedExpression
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::isFailOnUnresolvedExpression → NO_COVERAGE

2.2
Location : isFailOnUnresolvedExpression
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/DocxStamperConfiguration::isFailOnUnresolvedExpression → NO_COVERAGE

121

1.1
Location : setFailOnUnresolvedExpression
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setFailOnUnresolvedExpression → NO_COVERAGE

129

1.1
Location : isLeaveEmptyOnExpressionError
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/DocxStamperConfiguration::isLeaveEmptyOnExpressionError → NO_COVERAGE

2.2
Location : isLeaveEmptyOnExpressionError
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::isLeaveEmptyOnExpressionError → NO_COVERAGE

137

1.1
Location : isReplaceUnresolvedExpressions
Killed by : none
replaced boolean return with true for pro/verron/officestamper/core/DocxStamperConfiguration::isReplaceUnresolvedExpressions → NO_COVERAGE

2.2
Location : isReplaceUnresolvedExpressions
Killed by : none
replaced boolean return with false for pro/verron/officestamper/core/DocxStamperConfiguration::isReplaceUnresolvedExpressions → NO_COVERAGE

145

1.1
Location : getUnresolvedExpressionsDefaultValue
Killed by : none
replaced return value with "" for pro/verron/officestamper/core/DocxStamperConfiguration::getUnresolvedExpressionsDefaultValue → NO_COVERAGE

162

1.1
Location : unresolvedExpressionsDefaultValue
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::unresolvedExpressionsDefaultValue → NO_COVERAGE

178

1.1
Location : replaceUnresolvedExpressions
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::replaceUnresolvedExpressions → NO_COVERAGE

193

1.1
Location : leaveEmptyOnExpressionError
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::leaveEmptyOnExpressionError → NO_COVERAGE

210

1.1
Location : exposeInterfaceToExpressionLanguage
Killed by : pro.verron.officestamper.test.CustomFunctionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomFunctionTests]/[test-template:interfaces(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::exposeInterfaceToExpressionLanguage → KILLED

225

1.1
Location : addCommentProcessor
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#17]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCommentProcessor → KILLED

242

1.1
Location : getLineBreakPlaceholder
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#12]
replaced return value with "" for pro/verron/officestamper/core/DocxStamperConfiguration::getLineBreakPlaceholder → KILLED

254

1.1
Location : setLineBreakPlaceholder
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setLineBreakPlaceholder → KILLED

262

1.1
Location : getEvaluationContextConfigurer
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#22]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::getEvaluationContextConfigurer → KILLED

276

1.1
Location : setEvaluationContextConfigurer
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setEvaluationContextConfigurer → KILLED

281

1.1
Location : getSpelParserConfiguration
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#22]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::getSpelParserConfiguration → KILLED

295

1.1
Location : setSpelParserConfiguration
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setSpelParserConfiguration → KILLED

304

1.1
Location : getExpressionFunctions
Killed by : pro.verron.officestamper.test.RegressionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.RegressionTests]/[method:test64()]
replaced return value with Collections.emptyMap for pro/verron/officestamper/core/DocxStamperConfiguration::getExpressionFunctions → KILLED

313

1.1
Location : getCommentProcessors
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptyMap for pro/verron/officestamper/core/DocxStamperConfiguration::getCommentProcessors → KILLED

321

1.1
Location : getPreprocessors
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfEndnotes(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::getPreprocessors → KILLED

329

1.1
Location : getResolvers
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#12]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::getResolvers → KILLED

343

1.1
Location : setResolvers
Killed by : none
removed call to java/util/List::clear → SURVIVED
Covering tests

345

1.1
Location : setResolvers
Killed by : none
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setResolvers → SURVIVED
Covering tests

357

1.1
Location : addResolver
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#12]
removed call to java/util/List::addFirst → KILLED

358

1.1
Location : addResolver
Killed by : pro.verron.officestamper.test.DefaultTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.DefaultTests]/[test-template:features(java.lang.String, pro.verron.officestamper.api.OfficeStamperConfiguration, java.lang.Object, java.io.InputStream, java.lang.String)]/[test-template-invocation:#3]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addResolver → KILLED

366

1.1
Location : getExceptionResolver
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testCustomResolution(java.lang.String, boolean, boolean, boolean, boolean, boolean, java.lang.String, boolean, java.lang.String)]/[test-template-invocation:#22]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::getExceptionResolver → KILLED

377

1.1
Location : setExceptionResolver
Killed by : pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.FailOnUnresolvedPlaceholderTest]/[test-template:fails(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#1]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::setExceptionResolver → KILLED

385

1.1
Location : customFunctions
Killed by : pro.verron.officestamper.test.CustomFunctionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomFunctionTests]/[test-template:bifunctions(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::customFunctions → KILLED

398

1.1
Location : lambda$addCustomFunction$0
Killed by : pro.verron.officestamper.test.CustomFunctionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomFunctionTests]/[test-template:suppliers(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#1]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::lambda$addCustomFunction$0 → KILLED

2.2
Location : addCustomFunction
Killed by : pro.verron.officestamper.test.CustomFunctionTests.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.CustomFunctionTests]/[test-template:suppliers(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#1]
removed call to pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED

416

1.1
Location : addCustomFunction
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testStaticResolution(java.lang.String, boolean, boolean, boolean, java.lang.String, java.lang.String)]/[test-template-invocation:#6]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED

429

1.1
Location : addCustomFunction
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testStaticResolution(java.lang.String, boolean, boolean, boolean, java.lang.String, java.lang.String)]/[test-template-invocation:#6]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED

451

1.1
Location : addCustomFunction
Killed by : pro.verron.officestamper.test.ResolutionTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ResolutionTest]/[test-template:testStaticResolution(java.lang.String, boolean, boolean, boolean, java.lang.String, java.lang.String)]/[test-template-invocation:#6]
replaced return value with null for pro/verron/officestamper/core/DocxStamperConfiguration::addCustomFunction → KILLED

459

1.1
Location : getPostprocessors
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfEndnotes(pro.verron.officestamper.test.ContextFactory)]/[test-template-invocation:#2]
replaced return value with Collections.emptyList for pro/verron/officestamper/core/DocxStamperConfiguration::getPostprocessors → KILLED

Active mutators

Tests examined


Report generated by PIT 1.21.0