ParsedContent.java

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 1 1. toString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → NO_COVERAGE
		return asString();
59
	}
60
61
	@Override
62
	public boolean canProvideString() {
63 3 1. canProvideString : negated conditional → NO_COVERAGE
2. canProvideString : negated conditional → NO_COVERAGE
3. canProvideString : replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → NO_COVERAGE
		return generated instanceof MayHaveStringContent && ((MayHaveStringContent) generated).canProvideString();
64
	}
65
66
	@Override
67
	public String asString() {
68 2 1. asString : negated conditional → NO_COVERAGE
2. asString : negated conditional → NO_COVERAGE
		if(generated instanceof MayHaveStringContent && ((MayHaveStringContent) generated).canProvideString()) {
69 1 1. asString : replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE
			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 1 1. setStringContent : negated conditional → NO_COVERAGE
		if(generated instanceof UpdatableStringContent) {
77 1 1. setStringContent : removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → NO_COVERAGE
			((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 1 1. getPath : replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → NO_COVERAGE
		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
Location : toString
Killed by :
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::toString → NO_COVERAGE

63

1.1
Location : canProvideString
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : canProvideString
Killed by :
negated conditional → NO_COVERAGE

3.3
Location : canProvideString
Killed by :
replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::canProvideString → NO_COVERAGE

68

1.1
Location : asString
Killed by :
negated conditional → NO_COVERAGE

2.2
Location : asString
Killed by :
negated conditional → NO_COVERAGE

69

1.1
Location : asString
Killed by :
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE

71

1.1
Location : asString
Killed by :
replaced return value with "" for fr/sii/ogham/core/message/content/ParsedContent::asString → NO_COVERAGE

76

1.1
Location : setStringContent
Killed by :
negated conditional → NO_COVERAGE

77

1.1
Location : setStringContent
Killed by :
removed call to fr/sii/ogham/core/message/content/UpdatableStringContent::setStringContent → NO_COVERAGE

83

1.1
Location : hashCode
Killed by :
replaced int return with 0 for fr/sii/ogham/core/message/content/ParsedContent::hashCode → NO_COVERAGE

88

1.1
Location : equals
Killed by :
replaced boolean return with false for fr/sii/ogham/core/message/content/ParsedContent::equals → NO_COVERAGE

2.2
Location : equals
Killed by :
replaced boolean return with true for fr/sii/ogham/core/message/content/ParsedContent::equals → NO_COVERAGE

93

1.1
Location : getPath
Killed by :
replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getPath → NO_COVERAGE

97

1.1
Location : getSource
Killed by :
replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getSource → NO_COVERAGE

101

1.1
Location : getGenerated
Killed by :
replaced return value with null for fr/sii/ogham/core/message/content/ParsedContent::getGenerated → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.13.1