This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch 1.X in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
commit 89505781d417ea1419f68398f49eeed32059d36c Author: Gary Gregory <[email protected]> AuthorDate: Wed Jul 24 08:40:53 2024 -0400 Use compact array declaration - Remove redundant call to super() - Remove redundant parens - No need to nest --- .../commons/beanutils/BeanToPropertyValueTransformer.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java b/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java index 59cf9179..ef40f3d3 100644 --- a/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java +++ b/src/main/java/org/apache/commons/beanutils/BeanToPropertyValueTransformer.java @@ -117,15 +117,12 @@ public class BeanToPropertyValueTransformer implements Transformer { * empty. */ public BeanToPropertyValueTransformer(final String propertyName, final boolean ignoreNull) { - super(); - - if ((propertyName != null) && (propertyName.length() > 0)) { - this.propertyName = propertyName; - this.ignoreNull = ignoreNull; - } else { + if (propertyName == null || propertyName.length() <= 0) { throw new IllegalArgumentException( "propertyName cannot be null or empty"); } + this.propertyName = propertyName; + this.ignoreNull = ignoreNull; } /** @@ -144,6 +141,7 @@ public class BeanToPropertyValueTransformer implements Transformer { * provided. Or if an object in the property path provided is <code>null</code> and * <code>ignoreNull</code> is set to <code>false</code>. */ + @Override public Object transform(final Object object) { Object propertyValue = null; @@ -153,15 +151,14 @@ public class BeanToPropertyValueTransformer implements Transformer { } catch (final IllegalArgumentException e) { final String errorMsg = "Problem during transformation. Null value encountered in property path..."; - if (ignoreNull) { - log.warn("WARNING: " + errorMsg + e); - } else { + if (!ignoreNull) { final IllegalArgumentException iae = new IllegalArgumentException(errorMsg); if (!BeanUtils.initCause(iae, e)) { log.error(errorMsg, e); } throw iae; } + log.warn("WARNING: " + errorMsg + e); } catch (final IllegalAccessException e) { final String errorMsg = "Unable to access the property provided."; final IllegalArgumentException iae = new IllegalArgumentException(errorMsg);
