1 | package fr.sii.ogham.core.filler; | |
2 | ||
3 | import fr.sii.ogham.core.message.Message; | |
4 | import fr.sii.ogham.core.message.capability.HasSubject; | |
5 | import fr.sii.ogham.core.subject.provider.SubjectProvider; | |
6 | ||
7 | /** | |
8 | * Message filler that provides a subject to the message. If the message has | |
9 | * subject capability (implements {@link HasSubject}) and if the current subject | |
10 | * is null, then this filler asks to a {@link SubjectProvider} to generate a | |
11 | * subject. | |
12 | * | |
13 | * @author Aurélien Baudet | |
14 | * | |
15 | */ | |
16 | public class SubjectFiller implements MessageFiller { | |
17 | /** | |
18 | * The subject provider used to generate the subject | |
19 | */ | |
20 | private SubjectProvider subjectProvider; | |
21 | ||
22 | /** | |
23 | * Initializes the filler with the provider that will generate the subject | |
24 | * value | |
25 | * | |
26 | * @param subjectProvider | |
27 | * used to generate the subject value | |
28 | */ | |
29 | public SubjectFiller(SubjectProvider subjectProvider) { | |
30 | super(); | |
31 | this.subjectProvider = subjectProvider; | |
32 | } | |
33 | ||
34 | @Override | |
35 | public void fill(Message message) { | |
36 |
4
1. fill : negated conditional → NO_COVERAGE 2. fill : negated conditional → SURVIVED 3. fill : negated conditional → TIMED_OUT 4. fill : negated conditional → KILLED |
if (message instanceof HasSubject) { |
37 | HasSubject msg = (HasSubject) message; | |
38 | // only try to set the subject if none is provided | |
39 |
4
1. fill : negated conditional → SURVIVED 2. fill : negated conditional → NO_COVERAGE 3. fill : negated conditional → TIMED_OUT 4. fill : negated conditional → KILLED |
if (msg.getSubject() == null) { |
40 | String subject = subjectProvider.provide(message); | |
41 |
4
1. fill : negated conditional → SURVIVED 2. fill : negated conditional → NO_COVERAGE 3. fill : negated conditional → TIMED_OUT 4. fill : negated conditional → KILLED |
if (subject != null) { |
42 |
3
1. fill : removed call to fr/sii/ogham/core/message/capability/HasSubject::setSubject → NO_COVERAGE 2. fill : removed call to fr/sii/ogham/core/message/capability/HasSubject::setSubject → TIMED_OUT 3. fill : removed call to fr/sii/ogham/core/message/capability/HasSubject::setSubject → KILLED |
msg.setSubject(subject); |
43 | } | |
44 | } | |
45 | } | |
46 | } | |
47 | ||
48 | } | |
Mutations | ||
36 |
1.1 2.2 3.3 4.4 |
|
39 |
1.1 2.2 3.3 4.4 |
|
41 |
1.1 2.2 3.3 4.4 |
|
42 |
1.1 2.2 3.3 |