]> git.mxchange.org Git - jfinancials-war.git/commitdiff
avoid NPEs, if cellphone, fax or land-line instances are not set
authorRoland Häder <roland@mxchange.org>
Tue, 31 May 2016 13:12:18 +0000 (15:12 +0200)
committerRoland Haeder <roland@mxchange.org>
Wed, 1 Jun 2016 18:52:12 +0000 (20:52 +0200)
src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java

index d912dbbeff67b7c0c509092a0a7f4cf060830ae6..a07dc3fd99feb3892750937781916e02115e0e8e 100644 (file)
@@ -323,21 +323,27 @@ public class AddressbookAdminContactWebRequestBean extends BaseAddressbookContro
                this.setZipCode(contact.getContactZipCode());
 
                // ... cellphone data
-               this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
-               this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
-               this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
+               if (contact.getContactCellphoneNumber() instanceof DialableCellphoneNumber) {
+                       this.setCellphoneId(contact.getContactCellphoneNumber().getPhoneId());
+                       this.setCellphoneCarrier(contact.getContactCellphoneNumber().getCellphoneProvider());
+                       this.setCellphoneNumber(contact.getContactCellphoneNumber().getPhoneNumber());
+               }
 
                // ... fax data
-               this.setFaxId(contact.getContactFaxNumber().getPhoneId());
-               this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
-               this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
-               this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+               if (contact.getContactFaxNumber() instanceof DialableFaxNumber) {
+                       this.setFaxId(contact.getContactFaxNumber().getPhoneId());
+                       this.setFaxAreaCode(contact.getContactFaxNumber().getPhoneAreaCode());
+                       this.setFaxCountry(contact.getContactFaxNumber().getPhoneCountry());
+                       this.setFaxNumber(contact.getContactFaxNumber().getPhoneNumber());
+               }
 
                // .. land-line data
-               this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
-               this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
-               this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
-               this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+               if (contact.getContactLandLineNumber() instanceof DialableLandLineNumber) {
+                       this.setLandLineId(contact.getContactLandLineNumber().getPhoneId());
+                       this.setPhoneAreaCode(contact.getContactLandLineNumber().getPhoneAreaCode());
+                       this.setPhoneCountry(contact.getContactLandLineNumber().getPhoneCountry());
+                       this.setPhoneNumber(contact.getContactLandLineNumber().getPhoneNumber());
+               }
        }
 
        @Override