DisplayIfProcessor.java

1
package pro.verron.officestamper.preset.processors.displayif;
2
3
4
import org.jspecify.annotations.Nullable;
5
import org.jvnet.jaxb2_commons.ppp.Child;
6
import pro.verron.officestamper.api.CommentProcessor;
7
import pro.verron.officestamper.api.ProcessorContext;
8
import pro.verron.officestamper.preset.CommentProcessorFactory;
9
import pro.verron.officestamper.utils.wml.WmlUtils;
10
11
import java.util.ArrayList;
12
13
import static pro.verron.officestamper.api.OfficeStamperException.throwing;
14
15
/// Processor for the [CommentProcessorFactory.IDisplayIfProcessor] comment.
16
///
17
/// @author Joseph Verron
18
/// @author Tom Hombergs
19
/// @since 1.0.0
20
public class DisplayIfProcessor
21
        extends CommentProcessor
22
        implements CommentProcessorFactory.IDisplayIfProcessor {
23
24
25
    /// Creates a new [DisplayIfProcessor].
26
    ///
27
    /// @param processorContext the context in which this processor runs
28
    public DisplayIfProcessor(ProcessorContext processorContext) {
29
        super(processorContext);
30
    }
31
32
    @Override
33
    public void displayParagraphIfAbsent(@Nullable Object condition) {
34 2 1. displayParagraphIfAbsent : negated conditional → KILLED
2. displayParagraphIfAbsent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayParagraphIf → KILLED
        displayParagraphIf(condition == null);
35
    }
36
37
    @Override
38
    public void displayParagraphIf(@Nullable Boolean condition) {
39 1 1. displayParagraphIf : negated conditional → KILLED
        if (Boolean.TRUE.equals(condition)) return;
40
        context().paragraph()
41 1 1. displayParagraphIf : removed call to pro/verron/officestamper/api/Paragraph::remove → KILLED
                 .remove();
42
    }
43
44
    @Override
45
    public void displayParagraphIfPresent(@Nullable Object condition) {
46 2 1. displayParagraphIfPresent : negated conditional → KILLED
2. displayParagraphIfPresent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayParagraphIf → KILLED
        displayParagraphIf(condition != null);
47
    }
48
49
    @Override
50
    public void displayTableRowIf(@Nullable Boolean condition) {
51 1 1. displayTableRowIf : negated conditional → KILLED
        if (Boolean.TRUE.equals(condition)) return;
52
        context().tableRow()
53
                 .orElseThrow(throwing("Paragraph is not within a row!"))
54 1 1. displayTableRowIf : removed call to pro/verron/officestamper/api/Table$Row::remove → KILLED
                 .remove();
55
    }
56
57
    @Override
58
    public void displayTableRowIfPresent(@Nullable Object condition) {
59 2 1. displayTableRowIfPresent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableRowIf → KILLED
2. displayTableRowIfPresent : negated conditional → KILLED
        displayTableRowIf(condition != null);
60
    }
61
62
    @Override
63
    public void displayTableRowIfAbsent(@Nullable Object condition) {
64 2 1. displayTableRowIfAbsent : negated conditional → KILLED
2. displayTableRowIfAbsent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableRowIf → KILLED
        displayTableRowIf(condition == null);
65
    }
66
67
    @Override
68
    public void displayTableIf(@Nullable Boolean condition) {
69 1 1. displayTableIf : negated conditional → KILLED
        if (Boolean.TRUE.equals(condition)) return;
70
        context().table()
71
                 .orElseThrow(throwing("Paragraph is not within a table!"))
72 1 1. displayTableIf : removed call to pro/verron/officestamper/api/Table::remove → KILLED
                 .remove();
73
    }
74
75
    @Override
76
    public void displayTableIfPresent(@Nullable Object condition) {
77 2 1. displayTableIfPresent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableIf → KILLED
2. displayTableIfPresent : negated conditional → KILLED
        displayTableIf(condition != null);
78
    }
79
80
    @Override
81
    public void displayTableIfAbsent(@Nullable Object condition) {
82 2 1. displayTableIfAbsent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableIf → KILLED
2. displayTableIfAbsent : negated conditional → KILLED
        displayTableIf(condition == null);
83
    }
84
85
    @Override
86
    public void displayWordsIf(@Nullable Boolean condition) {
87 1 1. displayWordsIf : negated conditional → KILLED
        if (Boolean.TRUE.equals(condition)) return;
88
        var iterator = context().contentIterator();
89
        var toRemove = new ArrayList<Child>();
90 1 1. displayWordsIf : negated conditional → KILLED
        while (iterator.hasNext()) {
91
            var it = iterator.next();
92
            toRemove.add((Child) it);
93
        }
94 1 1. displayWordsIf : removed call to java/util/ArrayList::forEach → KILLED
        toRemove.forEach(WmlUtils::remove);
95
    }
96
97
    @Override
98
    public void displayWordsIfPresent(@Nullable Object condition) {
99 2 1. displayWordsIfPresent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayWordsIf → KILLED
2. displayWordsIfPresent : negated conditional → KILLED
        displayWordsIf(condition != null);
100
    }
101
102
    @Override
103
    public void displayWordsIfAbsent(@Nullable Object condition) {
104 2 1. displayWordsIfAbsent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayWordsIf → KILLED
2. displayWordsIfAbsent : negated conditional → KILLED
        displayWordsIf(condition == null);
105
    }
106
107
    @Override
108
    public void displayDocPartIf(@Nullable Boolean condition) {
109 1 1. displayDocPartIf : negated conditional → KILLED
        if (Boolean.TRUE.equals(condition)) return;
110
        comment().getParent()
111
                 .getContent()
112
                 .removeAll(comment().getElements());
113
    }
114
115
    @Override
116
    public void displayDocPartIfPresent(@Nullable Object condition) {
117 2 1. displayDocPartIfPresent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayDocPartIf → KILLED
2. displayDocPartIfPresent : negated conditional → KILLED
        displayDocPartIf(condition != null);
118
    }
119
120
    @Override
121
    public void displayDocPartIfAbsent(@Nullable Object condition) {
122 2 1. displayDocPartIfAbsent : removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayDocPartIf → KILLED
2. displayDocPartIfAbsent : negated conditional → KILLED
        displayDocPartIf(condition == null);
123
    }
124
}

Mutations

34

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

2.2
Location : displayParagraphIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayParagraphIf → KILLED

39

1.1
Location : displayParagraphIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableBug32Test(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

41

1.1
Location : displayParagraphIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableBug32Test(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/api/Paragraph::remove → KILLED

46

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

2.2
Location : displayParagraphIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfAbsentValue(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayParagraphIf → KILLED

51

1.1
Location : displayTableRowIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

54

1.1
Location : displayTableRowIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableRowsTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/api/Table$Row::remove → KILLED

59

1.1
Location : displayTableRowIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfAbsentValue(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableRowIf → KILLED

2.2
Location : displayTableRowIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

64

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

2.2
Location : displayTableRowIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableRowIf → KILLED

69

1.1
Location : displayTableIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

72

1.1
Location : displayTableIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfTableTest(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/api/Table::remove → KILLED

77

1.1
Location : displayTableIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfAbsentValue(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableIf → KILLED

2.2
Location : displayTableIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

82

1.1
Location : displayTableIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableIf → KILLED

2.2
Location : displayTableIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

87

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

90

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

94

1.1
Location : displayWordsIf
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfEndnotes(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
removed call to java/util/ArrayList::forEach → KILLED

99

1.1
Location : displayWordsIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfAbsentValue(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayWordsIf → KILLED

2.2
Location : displayWordsIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

104

1.1
Location : displayWordsIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayWordsIf → KILLED

2.2
Location : displayWordsIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

109

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

117

1.1
Location : displayDocPartIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfAbsentValue(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayDocPartIf → KILLED

2.2
Location : displayDocPartIfPresent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

122

1.1
Location : displayDocPartIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayDocPartIf → KILLED

2.2
Location : displayDocPartIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfHomer(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#1]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.25.5 support