}
/**
- * Updates cellphone data in contact instance. This method also removes the
- * cellphone instance if no provider is selected. A bean (mostly EJB) should
- * then make sure that the cellphone entry is being unlinked from contact
+ * Updates mobile data in contact instance. This method also removes the
+ * mobile instance if no provider is selected. A bean (mostly EJB) should
+ * then make sure that the mobile entry is being unlinked from contact
* instance or being removed, if no longer used.
* <p>
* @param contact Contact instance to update
- * @param cellphoneProvider New cellphone provider (or old)
- * @param cellphoneNumber New cellphone number (or old)
+ * @param mobileProvider New mobile provider (or old)
+ * @param mobileNumber New mobile number (or old)
* <p>
- * @return Whether the cellphone has been unlinked in contact object
+ * @return Whether the mobile has been unlinked in contact object
*/
- public static boolean updateCellPhoneNumber (final Contact contact, final MobileProvider cellphoneProvider, final Long cellphoneNumber) {
+ public static boolean updateCellPhoneNumber (final Contact contact, final MobileProvider mobileProvider, final Long mobileNumber) {
// At least contact must be valid
if (null == contact) {
// Throw NPE
throw new NullPointerException("contact is null"); //NOI18N
+ } else if ((mobileProvider instanceof MobileProvider) && (null == mobileNumber)) {
+ // Mobile provider given, but no number
+ throw new NullPointerException("mobileNumber is null"); //NOI18N
}
// Default is not unlinked
boolean isUnlinked = false;
- // Is there a cellphone number?
+ // Is there a mobile number?
if (contact.getContactMobileNumber() instanceof DialableMobileNumber) {
// Is provider null?
- if ((null == cellphoneProvider) || (null == cellphoneNumber) || (cellphoneNumber == 0)) {
+ if ((null == mobileProvider) || (null == mobileNumber) || (mobileNumber == 0)) {
// Remove instance
contact.setContactMobileNumber(null);
isUnlinked = true;
} else {
// Yes, then update as well
- contact.getContactMobileNumber().setMobileProvider(cellphoneProvider);
- contact.getContactMobileNumber().setPhoneNumber(cellphoneNumber);
+ contact.getContactMobileNumber().setMobileProvider(mobileProvider);
+ contact.getContactMobileNumber().setPhoneNumber(mobileNumber);
}
- } else if ((cellphoneProvider instanceof MobileProvider) && (cellphoneNumber > 0)) {
+ } else if ((mobileProvider instanceof MobileProvider) && (mobileNumber > 0)) {
// Create new instance
- DialableMobileNumber cellphone = new MobileNumber(cellphoneProvider, cellphoneNumber);
+ DialableMobileNumber mobile = new MobileNumber(mobileProvider, mobileNumber);
// Set it in contact
- contact.setContactMobileNumber(cellphone);
+ contact.setContactMobileNumber(mobile);
}
// Return status