This is an automated email from the ASF dual-hosted git repository. bvahdat pushed a commit to branch ObjectHelper-cleanup in repository https://gitbox.apache.org/repos/asf/camel.git
commit 957288f278a6c90b70c5f20fb870f512a56d964d Author: Babak Vahdat <bvah...@apache.org> AuthorDate: Mon Sep 13 13:40:12 2021 +0200 cleanup ObjectHelper utility --- .../java/org/apache/camel/util/ObjectHelper.java | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java b/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java index 96bf455..905ea0d 100644 --- a/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java +++ b/core/camel-util/src/main/java/org/apache/camel/util/ObjectHelper.java @@ -53,9 +53,6 @@ public final class ObjectHelper { private static final Logger LOG = LoggerFactory.getLogger(ObjectHelper.class); - private static final Float FLOAT_NAN = Float.NaN; - private static final Double DOUBLE_NAN = Double.NaN; - /** * Utility classes should not have a public constructor. */ @@ -176,7 +173,7 @@ public final class ObjectHelper { } /** - * Tests whether the value is <tt>null</tt> or an empty string. + * Tests whether the value is <tt>null</tt> or an empty string or an empty collection/map. * * @param value the value, if its a String it will be tested for text length as well * @return true if empty @@ -202,17 +199,7 @@ public final class ObjectHelper { * @return true if <b>not</b> empty */ public static boolean isNotEmpty(Object value) { - if (value == null) { - return false; - } else if (value instanceof String) { - return !((String) value).trim().isEmpty(); - } else if (value instanceof Collection) { - return !((Collection<?>) value).isEmpty(); - } else if (value instanceof Map) { - return !((Map<?, ?>) value).isEmpty(); - } else { - return true; - } + return !isEmpty(value); } /** @@ -1151,7 +1138,8 @@ public final class ObjectHelper { * @return <tt>true</tt> if its a {@link Float#NaN} or {@link Double#NaN}. */ public static boolean isNaN(Object value) { - return value instanceof Number && (FLOAT_NAN.equals(value) || DOUBLE_NAN.equals(value)); + return value instanceof Number + && (Float.isNaN(((Number) value).floatValue()) || Double.isNaN(((Number) value).doubleValue())); } /**