PhoneNumbersBuilder.java

1
package fr.sii.ogham.sms.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.sms.message.PhoneNumber;
8
import fr.sii.ogham.sms.message.addressing.AddressedPhoneNumber;
9
10
/**
11
 * Configures the phone number conversions (from a {@link PhoneNumber} to an
12
 * {@link AddressedPhoneNumber}).
13
 * 
14
 * The {@link PhoneNumber} is used by the developer to provide a simple phone
15
 * number without knowing how phone number works (no need to handle formats,
16
 * addressing, countries...). The {@link AddressedPhoneNumber} is used by Ogham
17
 * implementations to have a phone number that is usable by a technical system.
18
 * 
19
 * @author Aurélien Baudet
20
 *
21
 */
22
public class PhoneNumbersBuilder extends AbstractParent<SmsBuilder> implements Builder<PhoneNumberTranslatorPair> {
23
	private final BuildContext buildContext;
24
	private SenderNumberBuilder senderNumberBuilder;
25
	private RecipientNumberBuilder recipientNumberBuilder;
26
27
	/**
28
	 * Initializes the builder with a parent builder. The parent builder is used
29
	 * when calling {@link #and()} method. The {@link EnvironmentBuilder} is
30
	 * used to evaluate properties when {@link #build()} method is called.
31
	 * 
32
	 * @param parent
33
	 *            the parent builder
34
	 * @param buildContext
35
	 *            for registering instances and property evaluation
36
	 */
37
	public PhoneNumbersBuilder(SmsBuilder parent, BuildContext buildContext) {
38
		super(parent);
39
		this.buildContext = buildContext;
40
	}
41
42
	/**
43
	 * Configures the sender phone number conversion (from a {@link PhoneNumber}
44
	 * to an {@link AddressedPhoneNumber}).
45
	 * 
46
	 * The {@link PhoneNumber} is used by the developer to provide a simple
47
	 * phone number without knowing how phone number works (no need to handle
48
	 * formats, addressing, countries...). The {@link AddressedPhoneNumber} is
49
	 * used by Ogham implementations to have a phone number that is usable by a
50
	 * technical system.
51
	 * 
52
	 * @return the builder to configure the sender phone number
53
	 */
54
	public SenderNumberBuilder from() {
55 1 1. from : negated conditional → RUN_ERROR
		if (senderNumberBuilder == null) {
56
			senderNumberBuilder = new SenderNumberBuilder(this, buildContext);
57
		}
58 1 1. from : replaced return value with null for fr/sii/ogham/sms/builder/PhoneNumbersBuilder::from → RUN_ERROR
		return senderNumberBuilder;
59
	}
60
61
	/**
62
	 * Configures the recipient phone number conversion (from a
63
	 * {@link PhoneNumber} to an {@link AddressedPhoneNumber}).
64
	 * 
65
	 * The {@link PhoneNumber} is used by the developer to provide a simple
66
	 * phone number without knowing how phone number works (no need to handle
67
	 * formats, addressing, countries...). The {@link AddressedPhoneNumber} is
68
	 * used by Ogham implementations to have a phone number that is usable by a
69
	 * technical system.
70
	 * 
71
	 * @return the builder to configure the recipient phone number
72
	 */
73
	public RecipientNumberBuilder to() {
74 1 1. to : negated conditional → RUN_ERROR
		if (recipientNumberBuilder == null) {
75
			recipientNumberBuilder = new RecipientNumberBuilder(this, buildContext);
76
		}
77 1 1. to : replaced return value with null for fr/sii/ogham/sms/builder/PhoneNumbersBuilder::to → RUN_ERROR
		return recipientNumberBuilder;
78
	}
79
80
	@Override
81
	public PhoneNumberTranslatorPair build() {
82 1 1. build : replaced return value with null for fr/sii/ogham/sms/builder/PhoneNumbersBuilder::build → RUN_ERROR
		return buildContext.register(new PhoneNumberTranslatorPair(senderNumberBuilder.build(), recipientNumberBuilder.build()));
83
	}
84
}

Mutations

55

1.1
Location : from
Killed by :
negated conditional → RUN_ERROR

58

1.1
Location : from
Killed by :
replaced return value with null for fr/sii/ogham/sms/builder/PhoneNumbersBuilder::from → RUN_ERROR

74

1.1
Location : to
Killed by :
negated conditional → RUN_ERROR

77

1.1
Location : to
Killed by :
replaced return value with null for fr/sii/ogham/sms/builder/PhoneNumbersBuilder::to → RUN_ERROR

82

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

Active mutators

Tests examined


Report generated by PIT 1.13.1