SmsCoding.java

1
package fr.sii.ogham.sms.sender.impl.ovh;
2
3
import java.util.regex.Pattern;
4
5
import fr.sii.ogham.core.convert.StringToEnumConverter.FactoryMethod;
6
7
@FactoryMethod(name="from")
8
public enum SmsCoding {
9
	/**
10
	 * 7bit encoding
11
	 */
12
	GSM7(1),
13
	/**
14
	 * 16bit encoding
15
	 */
16
	UNICODE(2);
17
18
	private static final Pattern IS_NUMBER = Pattern.compile("1|2");
19
	private final int value;
20
21
	SmsCoding(int value) {
22
		this.value = value;
23
	}
24
25
	public int getValue() {
26 2 1. getValue : replaced int return with 0 for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::getValue → NO_COVERAGE
2. getValue : replaced int return with 0 for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::getValue → KILLED
		return value;
27
	}
28
29
	/**
30
	 * Returns {@link SmsCoding} either from constant name ("GSM7" or "UNICODE")
31
	 * or from value ("1" or "2").
32
	 * 
33
	 * @param nameOrValue
34
	 *            the name or value as string
35
	 * @return the corresponding {@link SmsCoding}
36
	 */
37
	public static SmsCoding from(String nameOrValue) {
38 2 1. from : negated conditional → NO_COVERAGE
2. from : negated conditional → KILLED
		if (nameOrValue == null) {
39
			throw new IllegalArgumentException("Invalid SmsCoding (null)");
40
		}
41 2 1. from : negated conditional → NO_COVERAGE
2. from : negated conditional → KILLED
		if (IS_NUMBER.matcher(nameOrValue).matches()) {
42 2 1. from : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → NO_COVERAGE
2. from : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → KILLED
			return from(Integer.parseInt(nameOrValue));
43
		}
44 2 1. from : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → NO_COVERAGE
2. from : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → KILLED
		return valueOf(nameOrValue);
45
	}
46
47
	/**
48
	 * Returns {@link SmsCoding} according to the value:
49
	 * <ul>
50
	 * <li>1: GSM7</li>
51
	 * <li>2: UNICODE</li>
52
	 * </ul>
53
	 * 
54
	 * @param value
55
	 *            the value
56
	 * @return the corresponding {@link SmsCoding}
57
	 */
58
	public static SmsCoding from(int value) {
59
		for (SmsCoding coding : values()) {
60 2 1. from : negated conditional → NO_COVERAGE
2. from : negated conditional → KILLED
			if (coding.getValue() == value) {
61 2 1. from : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → NO_COVERAGE
2. from : replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → KILLED
				return coding;
62
			}
63
		}
64
		throw new IllegalArgumentException("Invalid SmsCoding value: " + value);
65
	}
66
}

Mutations

26

1.1
Location : getValue
Killed by : none
replaced int return with 0 for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::getValue → NO_COVERAGE

2.2
Location : getValue
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromInvalidValue(oghamovh.it.SmsCodingTest)
replaced int return with 0 for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::getValue → KILLED

38

1.1
Location : from
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : from
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromValidNameOrValue(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

41

1.1
Location : from
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromValidNameOrValue(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

2.2
Location : from
Killed by : none
negated conditional → NO_COVERAGE

42

1.1
Location : from
Killed by : none
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → NO_COVERAGE

2.2
Location : from
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromValidNameOrValue(oghamovh.it.SmsCodingTest)
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → KILLED

44

1.1
Location : from
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromValidNameOrValue(oghamovh.it.SmsCodingTest)
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → KILLED

2.2
Location : from
Killed by : none
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → NO_COVERAGE

60

1.1
Location : from
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : from
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromInvalidValue(oghamovh.it.SmsCodingTest)
negated conditional → KILLED

61

1.1
Location : from
Killed by : none
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → NO_COVERAGE

2.2
Location : from
Killed by : oghamovh.it.SmsCodingTest.smsCodingFromValidNameOrValue(oghamovh.it.SmsCodingTest)
replaced return value with null for fr/sii/ogham/sms/sender/impl/ovh/SmsCoding::from → KILLED

Active mutators

Tests examined


Report generated by PIT OGHAM