This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new 654f20d231 Utility class modernization
654f20d231 is described below
commit 654f20d2314399b80a0800927a619d70e86da96d
Author: James Bognar <[email protected]>
AuthorDate: Fri Nov 7 12:05:17 2025 -0500
Utility class modernization
---
.../org/apache/juneau/common/reflect/ClassInfo.java | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
index 2910136166..deaaff446c 100644
---
a/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
+++
b/juneau-core/juneau-common/src/main/java/org/apache/juneau/common/reflect/ClassInfo.java
@@ -262,12 +262,27 @@ public class ClassInfo extends ElementInfo implements
Annotatable {
/**
* Returns <jk>true</jk> if this type can be used as a parameter for
the specified object.
*
+ * <p>
+ * For null values, returns <jk>true</jk> unless this type is a
primitive
+ * (since primitives cannot accept null values in Java).
+ *
+ * <h5 class='section'>Examples:</h5>
+ * <ul class='spaced-list'>
+ * <li><c>ClassInfo.of(String.class).canAcceptArg("foo")</c> -
returns <jk>true</jk>
+ * <li><c>ClassInfo.of(String.class).canAcceptArg(null)</c> -
returns <jk>true</jk>
+ * <li><c>ClassInfo.of(int.class).canAcceptArg(5)</c> - returns
<jk>true</jk>
+ * <li><c>ClassInfo.of(int.class).canAcceptArg(null)</c> - returns
<jk>false</jk> (primitives can't be null)
+ * <li><c>ClassInfo.of(Integer.class).canAcceptArg(null)</c> -
returns <jk>true</jk>
+ * </ul>
+ *
* @param child The argument to check.
* @return <jk>true</jk> if this type can be used as a parameter for
the specified object.
*/
public boolean canAcceptArg(Object child) {
- if (inner == null || child == null)
+ if (inner == null)
return false;
+ if (child == null)
+ return ! isPrimitive(); // Primitives can't accept
null, all other types can
if (inner.isInstance(child))
return true;
if (this.isPrimitive() || child.getClass().isPrimitive()) {