From 0e1c786aae558ba9a972fbbb223ba965d8d88792 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Thu, 27 Jul 2017 22:39:58 +0200 Subject: [PATCH] Please cherry-pick: - improved exception message when the expected interface is not implemented (meaning wrong call) - now the value's simple class name is being included MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../AddressbookBusinessContactConverter.java | 8 ++++---- .../converter/contact/AddressbookContactConverter.java | 8 ++++---- .../converter/country/AddressbookCountryConverter.java | 8 ++++---- .../converter/fax/AddressbookFaxNumberConverter.java | 8 ++++---- .../landline/AddressbookLandLineNumberConverter.java | 8 ++++---- .../mobile/AddressbookMobileNumberConverter.java | 8 ++++---- .../AddressbookMobileProviderConverter.java | 8 ++++---- .../converter/user/AddressbookUserConverter.java | 8 ++++---- .../validator/user/AddressbookUserIdValidator.java | 2 +- 9 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/java/org/mxchange/addressbook/converter/businesscontact/AddressbookBusinessContactConverter.java b/src/java/org/mxchange/addressbook/converter/businesscontact/AddressbookBusinessContactConverter.java index 24cc4cbd..0af4cb53 100644 --- a/src/java/org/mxchange/addressbook/converter/businesscontact/AddressbookBusinessContactConverter.java +++ b/src/java/org/mxchange/addressbook/converter/businesscontact/AddressbookBusinessContactConverter.java @@ -44,7 +44,7 @@ public class AddressbookBusinessContactConverter implements Converter { private static BusinessDataSessionBeanRemote BUSINESS_CONTACT_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookBusinessContactConverter () { } @@ -100,15 +100,15 @@ public class AddressbookBusinessContactConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof Contact)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Contact.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement Contact.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((BusinessBasicData) value).getBusinessDataId()); } diff --git a/src/java/org/mxchange/addressbook/converter/contact/AddressbookContactConverter.java b/src/java/org/mxchange/addressbook/converter/contact/AddressbookContactConverter.java index 9cc95acf..6f4536f4 100644 --- a/src/java/org/mxchange/addressbook/converter/contact/AddressbookContactConverter.java +++ b/src/java/org/mxchange/addressbook/converter/contact/AddressbookContactConverter.java @@ -43,7 +43,7 @@ public class AddressbookContactConverter implements Converter { private static ContactSessionBeanRemote CONTACT_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookContactConverter () { } @@ -99,15 +99,15 @@ public class AddressbookContactConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof Contact)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Contact.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement Contact.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((Contact) value).getContactId()); } diff --git a/src/java/org/mxchange/addressbook/converter/country/AddressbookCountryConverter.java b/src/java/org/mxchange/addressbook/converter/country/AddressbookCountryConverter.java index 7293b9d4..7de49611 100644 --- a/src/java/org/mxchange/addressbook/converter/country/AddressbookCountryConverter.java +++ b/src/java/org/mxchange/addressbook/converter/country/AddressbookCountryConverter.java @@ -44,7 +44,7 @@ public class AddressbookCountryConverter implements Converter { private static CountrySingletonBeanRemote COUNTRY_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookCountryConverter () { } @@ -111,15 +111,15 @@ public class AddressbookCountryConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof Country)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement Country.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement Country.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((Country) value).getCountryId()); } diff --git a/src/java/org/mxchange/addressbook/converter/fax/AddressbookFaxNumberConverter.java b/src/java/org/mxchange/addressbook/converter/fax/AddressbookFaxNumberConverter.java index 3d1f7d73..753bc47d 100644 --- a/src/java/org/mxchange/addressbook/converter/fax/AddressbookFaxNumberConverter.java +++ b/src/java/org/mxchange/addressbook/converter/fax/AddressbookFaxNumberConverter.java @@ -44,7 +44,7 @@ public class AddressbookFaxNumberConverter implements Converter { private static PhoneSessionBeanRemote PHONE_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookFaxNumberConverter () { } @@ -107,15 +107,15 @@ public class AddressbookFaxNumberConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof DialableNumber)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement DialableNumber.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((DialableNumber) value).getPhoneId()); } diff --git a/src/java/org/mxchange/addressbook/converter/landline/AddressbookLandLineNumberConverter.java b/src/java/org/mxchange/addressbook/converter/landline/AddressbookLandLineNumberConverter.java index 8d718362..91e37aa5 100644 --- a/src/java/org/mxchange/addressbook/converter/landline/AddressbookLandLineNumberConverter.java +++ b/src/java/org/mxchange/addressbook/converter/landline/AddressbookLandLineNumberConverter.java @@ -44,7 +44,7 @@ public class AddressbookLandLineNumberConverter implements Converter { private static PhoneSessionBeanRemote PHONE_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookLandLineNumberConverter () { } @@ -100,15 +100,15 @@ public class AddressbookLandLineNumberConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof DialableNumber)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement DialableNumber.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((DialableNumber) value).getPhoneId()); } diff --git a/src/java/org/mxchange/addressbook/converter/mobile/AddressbookMobileNumberConverter.java b/src/java/org/mxchange/addressbook/converter/mobile/AddressbookMobileNumberConverter.java index aa5f8005..8bb07d26 100644 --- a/src/java/org/mxchange/addressbook/converter/mobile/AddressbookMobileNumberConverter.java +++ b/src/java/org/mxchange/addressbook/converter/mobile/AddressbookMobileNumberConverter.java @@ -44,7 +44,7 @@ public class AddressbookMobileNumberConverter implements Converter { private static PhoneSessionBeanRemote PHONE_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookMobileNumberConverter () { } @@ -100,15 +100,15 @@ public class AddressbookMobileNumberConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof DialableNumber)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement DialableNumber.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement DialableNumber.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((DialableNumber) value).getPhoneId()); } diff --git a/src/java/org/mxchange/addressbook/converter/mobileprovider/AddressbookMobileProviderConverter.java b/src/java/org/mxchange/addressbook/converter/mobileprovider/AddressbookMobileProviderConverter.java index fa42cfe0..c9f3accd 100644 --- a/src/java/org/mxchange/addressbook/converter/mobileprovider/AddressbookMobileProviderConverter.java +++ b/src/java/org/mxchange/addressbook/converter/mobileprovider/AddressbookMobileProviderConverter.java @@ -44,7 +44,7 @@ public class AddressbookMobileProviderConverter implements Converter { private static MobileProviderSingletonBeanRemote MOBILE_PROVIDER_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookMobileProviderConverter () { } @@ -111,15 +111,15 @@ public class AddressbookMobileProviderConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof MobileProvider)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement MobileProvider.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement MobileProvider.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((MobileProvider) value).getProviderId()); } diff --git a/src/java/org/mxchange/addressbook/converter/user/AddressbookUserConverter.java b/src/java/org/mxchange/addressbook/converter/user/AddressbookUserConverter.java index 3a6d706d..c888a3d8 100644 --- a/src/java/org/mxchange/addressbook/converter/user/AddressbookUserConverter.java +++ b/src/java/org/mxchange/addressbook/converter/user/AddressbookUserConverter.java @@ -43,7 +43,7 @@ public class AddressbookUserConverter implements Converter { private static UserSessionBeanRemote USER_BEAN; /** - * Initialization of this converter + * Default constructor */ public AddressbookUserConverter () { } @@ -99,15 +99,15 @@ public class AddressbookUserConverter implements Converter { @Override public String getAsString (final FacesContext context, final UIComponent component, final Object value) { // Is the object null? - if ((null == value) || ((String.valueOf(value)).isEmpty())) { + if ((null == value) || (String.valueOf(value).isEmpty())) { // Is null return ""; //NOI18N } else if (!(value instanceof User)) { // Not same interface - throw new IllegalArgumentException(MessageFormat.format("value {0} does not implement User.", value)); //NOI18N + throw new IllegalArgumentException(MessageFormat.format("value[]={0} does not implement User.", value.getClass().getSimpleName())); //NOI18N } - // Return category id + // Return id number return String.valueOf(((User) value).getUserId()); } } diff --git a/src/java/org/mxchange/addressbook/validator/user/AddressbookUserIdValidator.java b/src/java/org/mxchange/addressbook/validator/user/AddressbookUserIdValidator.java index 29ff683f..aca92c0b 100644 --- a/src/java/org/mxchange/addressbook/validator/user/AddressbookUserIdValidator.java +++ b/src/java/org/mxchange/addressbook/validator/user/AddressbookUserIdValidator.java @@ -49,7 +49,7 @@ public class AddressbookUserIdValidator extends BaseLongValidator implements Val private static final long serialVersionUID = 12_869_569_314_764_690L; /** - * Initialization of this converter + * Default constructor */ public AddressbookUserIdValidator () { } -- 2.39.5