CssHandlingBuilder.java

1
package fr.sii.ogham.email.builder;
2
3
import fr.sii.ogham.core.builder.Builder;
4
import fr.sii.ogham.core.builder.context.BuildContext;
5
import fr.sii.ogham.core.builder.env.EnvironmentBuilder;
6
import fr.sii.ogham.core.fluent.AbstractParent;
7
import fr.sii.ogham.core.translator.content.ContentTranslator;
8
9
/**
10
 * CSS handling consists of defining how CSS are inlined in the email. Inlining
11
 * CSS means that CSS styles are loaded and applied on the matching HTML nodes
12
 * using the {@code style} HTML attribute.
13
 * 
14
 * @author Aurélien Baudet
15
 *
16
 */
17
public class CssHandlingBuilder extends AbstractParent<EmailBuilder> implements Builder<ContentTranslator> {
18
	private final BuildContext buildContext;
19
	private CssInliningBuilder cssInliningBuilder;
20
21
	/**
22
	 * Initializes the builder with a parent builder. The parent builder is used
23
	 * when calling {@link #and()} method. The {@link EnvironmentBuilder} is
24
	 * used to evaluate properties when {@link #build()} method is called.
25
	 * 
26
	 * @param parent
27
	 *            the parent builder
28
	 * @param buildContext
29
	 *            for registering instances and property evaluation
30
	 */
31
	public CssHandlingBuilder(EmailBuilder parent, BuildContext buildContext) {
32
		super(parent);
33
		this.buildContext = buildContext;
34
	}
35
36
	/**
37
	 * Configures how CSS are applied on HTML emails.
38
	 * 
39
	 * Inlining CSS means that CSS styles are loaded and applied on the matching
40
	 * HTML nodes using the {@code style} HTML attribute.
41
	 * 
42
	 * @return the builder to configure how CSS styles are inlined
43
	 */
44
	public CssInliningBuilder inline() {
45 1 1. inline : negated conditional → RUN_ERROR
		if (cssInliningBuilder == null) {
46
			cssInliningBuilder = new CssInliningBuilder(this, buildContext);
47
		}
48 1 1. inline : replaced return value with null for fr/sii/ogham/email/builder/CssHandlingBuilder::inline → RUN_ERROR
		return cssInliningBuilder;
49
	}
50
51
	@Override
52
	public ContentTranslator build() {
53 1 1. build : negated conditional → RUN_ERROR
		if (cssInliningBuilder == null) {
54
			return null;
55
		}
56 1 1. build : replaced return value with null for fr/sii/ogham/email/builder/CssHandlingBuilder::build → RUN_ERROR
		return cssInliningBuilder.build();
57
	}
58
}

Mutations

45

1.1
Location : inline
Killed by :
negated conditional → RUN_ERROR

48

1.1
Location : inline
Killed by :
replaced return value with null for fr/sii/ogham/email/builder/CssHandlingBuilder::inline → RUN_ERROR

53

1.1
Location : build
Killed by :
negated conditional → RUN_ERROR

56

1.1
Location : build
Killed by :
replaced return value with null for fr/sii/ogham/email/builder/CssHandlingBuilder::build → RUN_ERROR

Active mutators

Tests examined


Report generated by PIT 1.13.1