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

Mutations

35

1.1
Location : displayParagraphIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
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:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayParagraphIf → KILLED

40

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

42

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

47

1.1
Location : displayParagraphIfPresent
Killed by : none
negated conditional → TIMED_OUT

2.2
Location : displayParagraphIfPresent
Killed by : none
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayParagraphIf → TIMED_OUT

52

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

55

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

60

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:#1]
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:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

65

1.1
Location : displayTableRowIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
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:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
removed call to pro/verron/officestamper/preset/processors/displayif/DisplayIfProcessor::displayTableRowIf → KILLED

70

1.1
Location : displayTableIf
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

73

1.1
Location : displayTableIf
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/Table::remove → KILLED

78

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:#1]
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:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

83

1.1
Location : displayTableIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(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 : displayTableIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

88

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:#2]
negated conditional → KILLED

91

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:#2]
negated conditional → KILLED

95

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:#2]
removed call to java/util/ArrayList::forEach → KILLED

100

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:#1]
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:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

105

1.1
Location : displayWordsIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(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 : displayWordsIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

110

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:#2]
negated conditional → KILLED

118

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:#1]
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:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

123

1.1
Location : displayDocPartIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(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 : displayDocPartIfAbsent
Killed by : pro.verron.officestamper.test.ProcessorDisplayIfTest.[engine:junit-jupiter]/[class:pro.verron.officestamper.test.ProcessorDisplayIfTest]/[test-template:conditionalDisplayOfBart(pro.verron.officestamper.test.utils.ContextFactory)]/[test-template-invocation:#2]
negated conditional → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.0