From: Roland Häder Date: Tue, 31 May 2016 13:12:18 +0000 (+0200) Subject: avoid NPEs, if cellphone, fax or land-line instances are not set X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=4c2cfa5fa3f39901c003708ddaca84dadb7325c1;p=jfinancials-war.git avoid NPEs, if cellphone, fax or land-line instances are not set --- diff --git a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java index d912dbbe..a07dc3fd 100644 --- a/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java +++ b/src/java/org/mxchange/addressbook/beans/contact/AddressbookAdminContactWebRequestBean.java @@ -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