All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.sii.ogham.sms.message.Contact Maven / Gradle / Ivy

package fr.sii.ogham.sms.message;

import fr.sii.ogham.core.util.EqualsBuilder;
import fr.sii.ogham.core.util.HashCodeBuilder;

/**
 * A SMS contact taht contains the following information:
 * 
    *
  • The name of the contact (optional)
  • *
  • The phone number of the contact
  • *
* * @author Aurélien Baudet * */ public class Contact { /** * The name of the contact */ private final String name; /** * The phone number for the contact */ private PhoneNumber phoneNumber; /** * Initialize the contact with its phone number as string. *

* No name is specified. *

* * @param phoneNumber * the phone number for the contact */ public Contact(String phoneNumber) { this(new PhoneNumber(phoneNumber)); } /** * Initialize the contact with its name and its phone number as string. * * @param name * the name of the contact * @param phoneNumber * the phone number for the contact as string */ public Contact(String name, String phoneNumber) { this(name, new PhoneNumber(phoneNumber)); } /** * Initialize the contact with its name and its phone number. *

* No name is specified. *

* * @param phoneNumber * the phone number for the contact */ public Contact(PhoneNumber phoneNumber) { this(null, phoneNumber); } /** * Initialize the contact with its name and its phone number. * * @param name * the name of the contact * @param phoneNumber * the phone number for the contact */ public Contact(String name, PhoneNumber phoneNumber) { super(); this.name = name; this.phoneNumber = phoneNumber; } public String getName() { return name; } public PhoneNumber getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(PhoneNumber phoneNumber) { this.phoneNumber = phoneNumber; } @Override public String toString() { StringBuilder builder = new StringBuilder(); if (name != null && !name.isEmpty()) { builder.append(name).append(" "); } builder.append("<").append(phoneNumber).append(">"); return builder.toString(); } @Override public int hashCode() { return new HashCodeBuilder().append(name, phoneNumber).hashCode(); } @Override public boolean equals(Object obj) { return new EqualsBuilder(this, obj).appendFields("name", "phoneNumber").isEqual(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy