OfficeStampers.java

1
package pro.verron.officestamper.preset;
2
3
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
4
import pro.verron.officestamper.api.OfficeStamper;
5
import pro.verron.officestamper.api.OfficeStamperConfiguration;
6
import pro.verron.officestamper.api.OfficeStamperException;
7
import pro.verron.officestamper.api.StreamStamper;
8
import pro.verron.officestamper.core.DocxStamper;
9
import pro.verron.officestamper.utils.openpackaging.OpenpackagingUtils;
10
11
/// [OfficeStampers] is a utility class that provides factory methods for creating document stampers for Office
12
/// documents. This class offers convenient methods to create stampers for DOCX documents with various configurations.
13
///
14
/// The stampers created by this utility can apply various preprocessing steps to enhance the document processing
15
/// capabilities.
16
public class OfficeStampers {
17
18
    private OfficeStampers() {
19
        throw new OfficeStamperException("Utility classes should not be instantiated");
20
    }
21
22
    /// Creates a new instance of a [StreamStamper] for handling [WordprocessingMLPackage] documents with a default full
23
    /// configuration.
24
    ///
25
    /// @return a [StreamStamper] instance for stamping [WordprocessingMLPackage] documents
26
    ///
27
    /// @see OfficeStamperConfigurations#full()
28
    public static StreamStamper<WordprocessingMLPackage> docxStamper() {
29 1 1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE
        return docxStamper(OfficeStamperConfigurations.full());
30
    }
31
32
    /// Creates a [StreamStamper] instance that processes [WordprocessingMLPackage] (DOCX) documents by applying
33
    /// stamping with the given configuration.
34
    ///
35
    /// The returned stamper is designed to handle the transformation of DOCX templates using provided context data.
36
    ///
37
    /// @param configuration an instance of [OfficeStamperConfiguration] that defines the behavior and
38
    ///         preprocessing steps of the stamper
39
    ///
40
    /// @return a [StreamStamper] of [WordprocessingMLPackage] configured to process DOCX documents
41
    public static StreamStamper<WordprocessingMLPackage> docxStamper(OfficeStamperConfiguration configuration) {
42
        var stamper = docxPackageStamper(configuration);
43 1 1. docxStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE
        return new StreamStamper<>(OpenpackagingUtils::loadWord, stamper, OpenpackagingUtils::exportWord);
44
    }
45
46
    /// Creates an [OfficeStamper] instance for processing [WordprocessingMLPackage] documents with the specified
47
    /// configuration.
48
    ///
49
    /// @param configuration an instance of [OfficeStamperConfiguration] that defines the behavior of the
50
    ///         stamper
51
    ///
52
    /// @return an [OfficeStamper] for [WordprocessingMLPackage] configured to process DOCX documents
53
    public static OfficeStamper<WordprocessingMLPackage> docxPackageStamper(OfficeStamperConfiguration configuration) {
54 1 1. docxPackageStamper : replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxPackageStamper → KILLED
        return new DocxStamper(configuration);
55
    }
56
}

Mutations

29

1.1
Location : docxStamper
Killed by : none
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE

43

1.1
Location : docxStamper
Killed by : none
replaced return value with null for pro/verron/officestamper/preset/OfficeStampers::docxStamper → NO_COVERAGE

54

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

Active mutators

Tests examined


Report generated by PIT 1.22.0