2 * Copyright (C) 2016 Roland Haeder
\r
4 * This program is free software: you can redistribute it and/or modify
\r
5 * it under the terms of the GNU General Public License as published by
\r
6 * the Free Software Foundation, either version 3 of the License, or
\r
7 * (at your option) any later version.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
14 * You should have received a copy of the GNU General Public License
\r
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
\r
17 package org.mxchange.jcontacts.contact.utils;
\r
19 import java.text.MessageFormat;
\r
20 import org.mxchange.jcontacts.contact.Contact;
\r
21 import org.mxchange.jcore.BaseFrameworkSystem;
\r
22 import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
\r
23 import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
\r
24 import org.mxchange.jphone.phonenumbers.mobileprovider.MobileProvider;
\r
27 * Utilities for contacts
\r
29 * @author Roland Haeder<roland@mxchange.org>
\r
31 public class ContactUtils extends BaseFrameworkSystem {
\r
33 public static void updateCellPhoneNumber (final Contact contact, final MobileProvider cellphoneProvider, final Long cellphoneNumber) {
\r
34 // Is there a cellphone number?
\r
35 if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
\r
37 System.out.println(MessageFormat.format("updateCellPhoneNumber: cellPhoneId={0}", contact.getContactCellphoneNumber().getPhoneId())); //NOI18N
\r
39 // Is provider null?
\r
40 if (null == cellphoneProvider) {
\r
42 contact.setContactCellphoneNumber(null);
\r
44 // Yes, then update as well
\r
45 contact.getContactCellphoneNumber().setCellphoneProvider(cellphoneProvider);
\r
46 contact.getContactCellphoneNumber().setPhoneNumber(cellphoneNumber);
\r
48 } else if ((cellphoneProvider instanceof MobileProvider) && (cellphoneNumber > 0)) {
\r
49 // Create new instance
\r
50 DialableCellphoneNumber cellphone = new CellphoneNumber(cellphoneProvider, cellphoneNumber);
\r
55 * Private constructor for utilities
\r
57 private ContactUtils () {
\r