1 | package fr.sii.ogham.core.message.content; | |
2 | ||
3 | import fr.sii.ogham.core.resource.path.ResourcePath; | |
4 | import fr.sii.ogham.core.template.context.Context; | |
5 | import fr.sii.ogham.core.util.EqualsBuilder; | |
6 | import fr.sii.ogham.core.util.HashCodeBuilder; | |
7 | ||
8 | /** | |
9 | * Represent a content that original content comes from a template. | |
10 | * | |
11 | * This is a decorator. It also implements several interfaces to delegate to decorated contents. | |
12 | * | |
13 | * @author Aurélien Baudet | |
14 | * | |
15 | */ | |
16 | public class ParsedContent implements MayHaveStringContent, UpdatableStringContent, HasResourcePath { | |
17 | /** | |
18 | * The template content used to generate the {@link Content} | |
19 | */ | |
20 | private final TemplateContent source; | |
21 | /** | |
22 | * The content that has been generated | |
23 | */ | |
24 | private final Content generated; | |
25 | ||
26 | /** | |
27 | * Initializes the content with template source and the generated content. | |
28 | * | |
29 | * @param source | |
30 | * the source that has been processed | |
31 | * @param generated | |
32 | * the generated output | |
33 | */ | |
34 | public ParsedContent(TemplateContent source, Content generated) { | |
35 | super(); | |
36 | this.source = source; | |
37 | this.generated = generated; | |
38 | } | |
39 | ||
40 | /** | |
41 | * Initializes the content with template source and the generated content. | |
42 | * | |
43 | * @param sourcePath | |
44 | * the source path that has been processed | |
45 | * @param sourceContext | |
46 | * the evaluation context | |
47 | * @param generated | |
48 | * the generated output as string | |
49 | */ | |
50 | public ParsedContent(ResourcePath sourcePath, Context sourceContext, String generated) { | |
51 | super(); | |
52 | this.source = new TemplateContent(sourcePath, sourceContext); | |
53 | this.generated = new StringContent(generated); | |
54 | } | |
55 | ||
56 | @Override | |
57 | public String toString() { | |
58 |
6
1. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → NO_COVERAGE 2. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → TIMED_OUT 3. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED 4. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED 5. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED 6. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → KILLED |
return asString(); |
59 | } | |
60 | ||
61 | @Override | |
62 | public boolean canProvideString() { | |
63 |
9
1. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → NO_COVERAGE 2. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → SURVIVED 3. canProvideString : negated conditional → NO_COVERAGE 4. canProvideString : negated conditional → NO_COVERAGE 5. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → TIMED_OUT 6. canProvideString : negated conditional → TIMED_OUT 7. canProvideString : negated conditional → TIMED_OUT 8. canProvideString : negated conditional → KILLED 9. canProvideString : negated conditional → KILLED |
return generated instanceof MayHaveStringContent && ((MayHaveStringContent) generated).canProvideString(); |
64 | } | |
65 | ||
66 | @Override | |
67 | public String asString() { | |
68 |
12
1. asString : negated conditional → NO_COVERAGE 2. asString : negated conditional → NO_COVERAGE 3. asString : negated conditional → TIMED_OUT 4. asString : negated conditional → TIMED_OUT 5. asString : negated conditional → KILLED 6. asString : negated conditional → KILLED 7. asString : negated conditional → KILLED 8. asString : negated conditional → KILLED 9. asString : negated conditional → KILLED 10. asString : negated conditional → KILLED 11. asString : negated conditional → KILLED 12. asString : negated conditional → KILLED |
if(generated instanceof MayHaveStringContent && ((MayHaveStringContent) generated).canProvideString()) { |
69 |
6
1. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE 2. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → TIMED_OUT 3. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED 4. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED 5. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED 6. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → KILLED |
return ((MayHaveStringContent) generated).asString(); |
70 | } | |
71 |
1
1. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE |
return null; |
72 | } | |
73 | ||
74 | @Override | |
75 | public void setStringContent(String content) { | |
76 |
2
1. setStringContent : negated conditional → NO_COVERAGE 2. setStringContent : negated conditional → KILLED |
if(generated instanceof UpdatableStringContent) { |
77 |
2
1. setStringContent : removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → NO_COVERAGE 2. setStringContent : removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → KILLED |
((UpdatableStringContent) generated).setStringContent(content); |
78 | } | |
79 | } | |
80 | ||
81 | @Override | |
82 | public int hashCode() { | |
83 |
1
1. hashCode : replaced int return with 0 for fr/sii/ogham/core/message/content/ParsedContent::hashCode → NO_COVERAGE |
return new HashCodeBuilder().append(source).append(generated).hashCode(); |
84 | } | |
85 | ||
86 | @Override | |
87 | public boolean equals(Object obj) { | |
88 |
2
1. equals : replaced boolean return with false for fr/sii/ogham/core/message/content/ParsedContent::equals → NO_COVERAGE 2. equals : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::equals → NO_COVERAGE |
return new EqualsBuilder(this, obj).appendFields("source", "generated").isEqual(); |
89 | } | |
90 | ||
91 | @Override | |
92 | public ResourcePath getPath() { | |
93 |
2
1. getPath : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → NO_COVERAGE 2. getPath : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → KILLED |
return source.getPath(); |
94 | } | |
95 | ||
96 | public TemplateContent getSource() { | |
97 |
1
1. getSource : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getSource → NO_COVERAGE |
return source; |
98 | } | |
99 | ||
100 | public Content getGenerated() { | |
101 |
1
1. getGenerated : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getGenerated → NO_COVERAGE |
return generated; |
102 | } | |
103 | | |
104 | } | |
Mutations | ||
58 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
63 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
68 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 11.11 12.12 |
|
69 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
71 |
1.1 |
|
76 |
1.1 2.2 |
|
77 |
1.1 2.2 |
|
83 |
1.1 |
|
88 |
1.1 2.2 |
|
93 |
1.1 2.2 |
|
97 |
1.1 |
|
101 |
1.1 |