1 | package pro.verron.officestamper.core; | |
2 | ||
3 | import pro.verron.officestamper.api.*; | |
4 | ||
5 | import java.util.AbstractMap; | |
6 | import java.util.Map; | |
7 | import java.util.Set; | |
8 | ||
9 | /** | |
10 | * The CommentProcessors class is a specialized extension of {@link AbstractMap} that serves as a registry | |
11 | * for associating {@link CommentProcessor} instances with their corresponding {@link Class} types. | |
12 | * This class facilitates the management and execution of multiple {@link CommentProcessor} objects by | |
13 | * coordinating their lifecycle operations, such as setting contexts and committing changes. | |
14 | */ | |
15 | public class CommentProcessors | |
16 | extends AbstractMap<Class<?>, CommentProcessor> { | |
17 | ||
18 | private final Map<Class<?>, CommentProcessor> processors; | |
19 | ||
20 | /** | |
21 | * Constructs a new CommentProcessors instance with the specified map of processors. | |
22 | * | |
23 | * @param processors a map associating {@link Class} types with their corresponding {@link CommentProcessor} | |
24 | * instances; this map serves as the registry for managing and executing the processors | |
25 | */ | |
26 | public CommentProcessors(Map<Class<?>, CommentProcessor> processors) { | |
27 | this.processors = processors; | |
28 | } | |
29 | ||
30 | /** | |
31 | * Sets the context for all registered {@link CommentProcessor} instances. | |
32 | * This method delegates the provided {@link ProcessorContext} to each processor in the registry, | |
33 | * enabling them to operate within the specified context. | |
34 | * | |
35 | * @param context the context in which the processors will operate, containing details about | |
36 | * the paragraph, run, comment, and placeholder being processed | |
37 | */ | |
38 | void setContext(ProcessorContext context) { | |
39 | for (var processor : processors.values()) { | |
40 |
1
1. setContext : removed call to pro/verron/officestamper/api/CommentProcessor::setProcessorContext → KILLED |
processor.setProcessorContext(context); |
41 | } | |
42 | } | |
43 | ||
44 | /** | |
45 | * Commits all changes made to the provided {@link DocxPart} across all registered {@link CommentProcessor} instances. | |
46 | * This method ensures that each processor finalizes its processing for the given document part and resets its | |
47 | * internal state to prepare for subsequent operations. | |
48 | * | |
49 | * @param source the {@link DocxPart} instance representing the part of the document that is being processed; | |
50 | * used as input for committing changes and finalizing the processing tasks of the comment processors | |
51 | */ | |
52 | void commitChanges(DocxPart source) { | |
53 | for (var processor : processors.values()) { | |
54 |
1
1. commitChanges : removed call to pro/verron/officestamper/api/CommentProcessor::commitChanges → KILLED |
processor.commitChanges(source); |
55 |
1
1. commitChanges : removed call to pro/verron/officestamper/api/CommentProcessor::reset → KILLED |
processor.reset(); |
56 | } | |
57 | } | |
58 | ||
59 | @Override public Set<Entry<Class<?>, CommentProcessor>> entrySet() { | |
60 |
1
1. entrySet : replaced return value with Collections.emptySet for pro/verron/officestamper/core/CommentProcessors::entrySet → KILLED |
return processors.entrySet(); |
61 | } | |
62 | } | |
Mutations | ||
40 |
1.1 |
|
54 |
1.1 |
|
55 |
1.1 |
|
60 |
1.1 |