]> git.mxchange.org Git - jcontacts-core.git/blob - src/org/mxchange/jcontacts/contact/utils/ContactUtils.java
added utils class for contacts
[jcontacts-core.git] / src / org / mxchange / jcontacts / contact / utils / ContactUtils.java
1 /*\r
2  * Copyright (C) 2016 Roland Haeder\r
3  *\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
8  *\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
13  *\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
16  */\r
17 package org.mxchange.jcontacts.contact.utils;\r
18 \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
25 \r
26 /**\r
27  * Utilities for contacts\r
28  * <p>\r
29  * @author Roland Haeder<roland@mxchange.org>\r
30  */\r
31 public class ContactUtils extends BaseFrameworkSystem {\r
32 \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
36                         // Debug message\r
37                         System.out.println(MessageFormat.format("updateCellPhoneNumber: cellPhoneId={0}", contact.getContactCellphoneNumber().getPhoneId())); //NOI18N\r
38 \r
39                         // Is provider null?\r
40                         if (null == cellphoneProvider) {\r
41                                 // Remove instance\r
42                                 contact.setContactCellphoneNumber(null);\r
43                         } else {\r
44                                 // Yes, then update as well\r
45                                 contact.getContactCellphoneNumber().setCellphoneProvider(cellphoneProvider);\r
46                                 contact.getContactCellphoneNumber().setPhoneNumber(cellphoneNumber);\r
47                         }\r
48                 } else if ((cellphoneProvider instanceof MobileProvider) && (cellphoneNumber > 0)) {\r
49                         // Create new instance\r
50                         DialableCellphoneNumber cellphone = new CellphoneNumber(cellphoneProvider, cellphoneNumber);\r
51                 }\r
52         }\r
53 \r
54         /**\r
55          * Private constructor for utilities\r
56          */\r
57         private ContactUtils () {\r
58         }\r
59 \r
60 }\r