[
https://issues.apache.org/jira/browse/LANG-1659?focusedWorklogId=596653&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-596653
]
ASF GitHub Bot logged work on LANG-1659:
----------------------------------------
Author: ASF GitHub Bot
Created on: 14/May/21 13:34
Start Date: 14/May/21 13:34
Worklog Time Spent: 10m
Work Description: garydgregory commented on a change in pull request #754:
URL: https://github.com/apache/commons-lang/pull/754#discussion_r632525243
##########
File path: src/main/java/org/apache/commons/lang3/ObjectUtils.java
##########
@@ -951,6 +951,25 @@ their constant using one of the CONST() utility methods,
instead:
public final static int MAGIC_NUMBER = CONST(5);
*/
+ /**
+ * <p>Determine whether the given object is an array:
+ * either an Object array or a primitive array.
Review comment:
Close HTML tags.
##########
File path: src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
##########
@@ -586,6 +586,23 @@ public void testIsEmpty() {
assertFalse(ObjectUtils.isEmpty(NON_EMPTY_MAP));
}
+ /**
+ * Test for {@link ObjectUtils#isArray(Object)}.
+ */
+ @Test
+ public void testArray() {
+ assertFalse(ObjectUtils.isArray(null));
+ assertFalse(ObjectUtils.isArray(""));
+ assertFalse(ObjectUtils.isArray("abg"));
+ assertFalse(ObjectUtils.isArray(123));
+
+ assertTrue(ObjectUtils.isArray(NON_EMPTY_ARRAY));
+ assertTrue(ObjectUtils.isArray(new int[] {}));
+ assertTrue(ObjectUtils.isArray(new int[]{1, 2, 3}));
+
Review comment:
Remove extra blank lines.
##########
File path: src/main/java/org/apache/commons/lang3/ObjectUtils.java
##########
@@ -951,6 +951,25 @@ their constant using one of the CONST() utility methods,
instead:
public final static int MAGIC_NUMBER = CONST(5);
*/
+ /**
+ * <p>Determine whether the given object is an array:
Review comment:
I've been using "Tests..." for `is*` methods. If you really want to keep
"Determine" then it should be "Determines", also the main part of the Javadoc
should mention that the method is null-safe, for example: "Test whether the
given object is an Object array or a primitive array in a null-safe manner.".
##########
File path: src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java
##########
@@ -586,6 +586,23 @@ public void testIsEmpty() {
assertFalse(ObjectUtils.isEmpty(NON_EMPTY_MAP));
}
+ /**
+ * Test for {@link ObjectUtils#isArray(Object)}.
+ */
+ @Test
+ public void testArray() {
+ assertFalse(ObjectUtils.isArray(null));
+ assertFalse(ObjectUtils.isArray(""));
+ assertFalse(ObjectUtils.isArray("abg"));
+ assertFalse(ObjectUtils.isArray(123));
+
+ assertTrue(ObjectUtils.isArray(NON_EMPTY_ARRAY));
+ assertTrue(ObjectUtils.isArray(new int[] {}));
Review comment:
Might as well test with all of our own arrays like the `EMPTY_*` arrays.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 596653)
Time Spent: 1h (was: 50m)
> Method to check if an object it's an array
> ------------------------------------------
>
> Key: LANG-1659
> URL: https://issues.apache.org/jira/browse/LANG-1659
> Project: Commons Lang
> Issue Type: Improvement
> Reporter: Arturo Bernal
> Priority: Major
> Labels: pull-requests-available
> Time Spent: 1h
> Remaining Estimate: 0h
>
> The idea it's have a method that determine whether the given object is an
> array. Change all the reference of .getClass().isArray() in favor of
> {code:java}
> ObjectUtils.isArray(value)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)