| 1 | package fr.sii.ogham.sms.message; | |
| 2 | ||
| 3 | import fr.sii.ogham.core.util.EqualsBuilder; | |
| 4 | import fr.sii.ogham.core.util.HashCodeBuilder; | |
| 5 | ||
| 6 | /** | |
| 7 | * A SMS contact taht contains the following information: | |
| 8 | * <ul> | |
| 9 | * <li>The name of the contact (optional)</li> | |
| 10 | * <li>The phone number of the contact</li> | |
| 11 | * </ul> | |
| 12 | * | |
| 13 | * @author Aurélien Baudet | |
| 14 | * | |
| 15 | */ | |
| 16 | public class Contact { | |
| 17 | /** | |
| 18 | * The name of the contact | |
| 19 | */ | |
| 20 | private final String name; | |
| 21 | ||
| 22 | /** | |
| 23 | * The phone number for the contact | |
| 24 | */ | |
| 25 | private PhoneNumber phoneNumber; | |
| 26 | ||
| 27 | /** | |
| 28 | * Initialize the contact with its phone number as string. | |
| 29 | * <p> | |
| 30 | * No name is specified. | |
| 31 | * </p> | |
| 32 | * | |
| 33 | * @param phoneNumber | |
| 34 | * the phone number for the contact | |
| 35 | */ | |
| 36 | public Contact(String phoneNumber) { | |
| 37 | this(new PhoneNumber(phoneNumber)); | |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| 41 | * Initialize the contact with its name and its phone number as string. | |
| 42 | * | |
| 43 | * @param name | |
| 44 | * the name of the contact | |
| 45 | * @param phoneNumber | |
| 46 | * the phone number for the contact as string | |
| 47 | */ | |
| 48 | public Contact(String name, String phoneNumber) { | |
| 49 | this(name, new PhoneNumber(phoneNumber)); | |
| 50 | } | |
| 51 | ||
| 52 | /** | |
| 53 | * Initialize the contact with its name and its phone number. | |
| 54 | * <p> | |
| 55 | * No name is specified. | |
| 56 | * </p> | |
| 57 | * | |
| 58 | * @param phoneNumber | |
| 59 | * the phone number for the contact | |
| 60 | */ | |
| 61 | public Contact(PhoneNumber phoneNumber) { | |
| 62 | this(null, phoneNumber); | |
| 63 | } | |
| 64 | ||
| 65 | /** | |
| 66 | * Initialize the contact with its name and its phone number. | |
| 67 | * | |
| 68 | * @param name | |
| 69 | * the name of the contact | |
| 70 | * @param phoneNumber | |
| 71 | * the phone number for the contact | |
| 72 | */ | |
| 73 | public Contact(String name, PhoneNumber phoneNumber) { | |
| 74 | super(); | |
| 75 | this.name = name; | |
| 76 | this.phoneNumber = phoneNumber; | |
| 77 | } | |
| 78 | ||
| 79 | public String getName() { | |
| 80 |
3
1. getName : replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → SURVIVED 2. getName : replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → NO_COVERAGE 3. getName : replaced return value with "" for fr/sii/ogham/sms/message/Contact::getName → KILLED |
return name; |
| 81 | } | |
| 82 | ||
| 83 | public PhoneNumber getPhoneNumber() { | |
| 84 |
6
1. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → NO_COVERAGE 2. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → TIMED_OUT 3. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED 4. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED 5. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED 6. getPhoneNumber : replaced return value with null for fr/sii/ogham/sms/message/Contact::getPhoneNumber → KILLED |
return phoneNumber; |
| 85 | } | |
| 86 | ||
| 87 | public void setPhoneNumber(PhoneNumber phoneNumber) { | |
| 88 | this.phoneNumber = phoneNumber; | |
| 89 | } | |
| 90 | ||
| 91 | ||
| 92 | @Override | |
| 93 | public String toString() { | |
| 94 | StringBuilder builder = new StringBuilder(); | |
| 95 |
4
1. toString : negated conditional → NO_COVERAGE 2. toString : negated conditional → SURVIVED 3. toString : negated conditional → NO_COVERAGE 4. toString : negated conditional → TIMED_OUT |
if (name != null && !name.isEmpty()) { |
| 96 | builder.append(name).append(" "); | |
| 97 | } | |
| 98 | builder.append("<").append(phoneNumber).append(">"); | |
| 99 |
3
1. toString : replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → NO_COVERAGE 2. toString : replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → SURVIVED 3. toString : replaced return value with "" for fr/sii/ogham/sms/message/Contact::toString → TIMED_OUT |
return builder.toString(); |
| 100 | } | |
| 101 | ||
| 102 | @Override | |
| 103 | public int hashCode() { | |
| 104 |
2
1. hashCode : replaced int return with 0 for fr/sii/ogham/sms/message/Contact::hashCode → NO_COVERAGE 2. hashCode : replaced int return with 0 for fr/sii/ogham/sms/message/Contact::hashCode → KILLED |
return new HashCodeBuilder().append(name, phoneNumber).hashCode(); |
| 105 | } | |
| 106 | ||
| 107 | @Override | |
| 108 | public boolean equals(Object obj) { | |
| 109 |
6
1. equals : replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → NO_COVERAGE 2. equals : replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → NO_COVERAGE 3. equals : replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → SURVIVED 4. equals : replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → KILLED 5. equals : replaced boolean return with false for fr/sii/ogham/sms/message/Contact::equals → KILLED 6. equals : replaced boolean return with true for fr/sii/ogham/sms/message/Contact::equals → KILLED |
return new EqualsBuilder(this, obj).appendFields("name", "phoneNumber").isEqual(); |
| 110 | } | |
| 111 | } | |
Mutations | ||
| 80 |
1.1 2.2 3.3 |
|
| 84 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 95 |
1.1 2.2 3.3 4.4 |
|
| 99 |
1.1 2.2 3.3 |
|
| 104 |
1.1 2.2 |
|
| 109 |
1.1 2.2 3.3 4.4 5.5 6.6 |