[GitHub] commons-lang pull request #357: Proposal for LANG-1421
Github user sparsick commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/357#discussion_r220118024 --- Diff: src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java --- @@ -148,11 +153,27 @@ public void testAnyNotNull() { assertTrue(ObjectUtils.anyNotNull(null, null, null, null, FOO, BAR)); } +/** + * Tests {@link ObjectUtils#anyNull(Object...)}. + */ +@Test +void testAnyNull() { +assertTrue(ObjectUtils.anyNull((Object) null)); +assertTrue(ObjectUtils.anyNull(null, null, null)); + +assertFalse(ObjectUtils.anyNull()); +assertFalse(ObjectUtils.anyNull((Object[]) null)); +assertFalse(ObjectUtils.anyNull(FOO)); +assertFalse(ObjectUtils.anyNull(null, FOO, null)); --- End diff -- Thank you. You are right. I will create a new commit. ---
[GitHub] commons-lang pull request #357: Proposal for LANG-1421
Github user aaabramov commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/357#discussion_r220096594 --- Diff: src/test/java/org/apache/commons/lang3/ObjectUtilsTest.java --- @@ -148,11 +153,27 @@ public void testAnyNotNull() { assertTrue(ObjectUtils.anyNotNull(null, null, null, null, FOO, BAR)); } +/** + * Tests {@link ObjectUtils#anyNull(Object...)}. + */ +@Test +void testAnyNull() { +assertTrue(ObjectUtils.anyNull((Object) null)); +assertTrue(ObjectUtils.anyNull(null, null, null)); + +assertFalse(ObjectUtils.anyNull()); +assertFalse(ObjectUtils.anyNull((Object[]) null)); +assertFalse(ObjectUtils.anyNull(FOO)); +assertFalse(ObjectUtils.anyNull(null, FOO, null)); --- End diff -- Should this really be `assertFalse`? `ObjectUtils.anyNull(null, null, null, null, FOO, BAR)` - should return `true`, because it has `null` elements in varargs. ---
[GitHub] commons-lang pull request #357: Proposal for LANG-1421
Github user sparsick commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/357#discussion_r219674807 --- Diff: src/main/java/org/apache/commons/lang3/ObjectUtils.java --- @@ -236,6 +236,39 @@ public static boolean anyNotNull(final Object... values) { return firstNonNull(values) != null; } +/** + * Checks if any value in the given array is {@code null}. + * + * + * If none of the values are {@code null} or the array is {@code null} + * or empty then {@code false} is returned. Otherwise {@code true} is returned. + * + * + * + * ObjectUtils.anyNull(*) = false + * ObjectUtils.anyNull(*, null) = true + * ObjectUtils.anyNull(null, *) = true + * ObjectUtils.anyNull(null, null, *, *)= true + * ObjectUtils.anyNull(null)= true + * ObjectUtils.anyNull(null, null) = true + * ObjectUtils.anyNull()= false + * ObjectUtils.anyNull((Object[]) null) = false + * + * + * @param values the values to test, may be {@code null} or empty + * @return {@code true} if there is at least one null value in the array, + * {@code false} if all values in the array are not {@code null}s. + * If the array is {@code null} or empty {@code fatolse} is also returned. --- End diff -- Thank you for reviewing. I don't find a better replacement for the if sentence. I hope it is ok. ---
[GitHub] commons-lang pull request #357: Proposal for LANG-1421
Github user andyklimczak commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/357#discussion_r219537218 --- Diff: src/main/java/org/apache/commons/lang3/ObjectUtils.java --- @@ -236,6 +236,39 @@ public static boolean anyNotNull(final Object... values) { return firstNonNull(values) != null; } +/** + * Checks if any value in the given array is {@code null}. + * + * + * If none of the values are {@code null} or the array is {@code null} + * or empty then {@code false} is returned. Otherwise {@code true} is returned. + * + * + * + * ObjectUtils.anyNull(*) = false + * ObjectUtils.anyNull(*, null) = true + * ObjectUtils.anyNull(null, *) = true + * ObjectUtils.anyNull(null, null, *, *)= true + * ObjectUtils.anyNull(null)= true + * ObjectUtils.anyNull(null, null) = true + * ObjectUtils.anyNull()= false + * ObjectUtils.anyNull((Object[]) null) = false + * + * + * @param values the values to test, may be {@code null} or empty + * @return {@code true} if there is at least one null value in the array, + * {@code false} if all values in the array are not {@code null}s. + * If the array is {@code null} or empty {@code fatolse} is also returned. --- End diff -- depending on how you feel, you could replace the `if the array is {@code null}` info with something about this method being null safe (to keep the wordage the same as other methods that use `null safe`) ---
[GitHub] commons-lang pull request #357: Proposal for LANG-1421
Github user andyklimczak commented on a diff in the pull request: https://github.com/apache/commons-lang/pull/357#discussion_r219536392 --- Diff: src/main/java/org/apache/commons/lang3/ObjectUtils.java --- @@ -236,6 +236,39 @@ public static boolean anyNotNull(final Object... values) { return firstNonNull(values) != null; } +/** + * Checks if any value in the given array is {@code null}. + * + * + * If none of the values are {@code null} or the array is {@code null} + * or empty then {@code false} is returned. Otherwise {@code true} is returned. + * + * + * + * ObjectUtils.anyNull(*) = false + * ObjectUtils.anyNull(*, null) = true + * ObjectUtils.anyNull(null, *) = true + * ObjectUtils.anyNull(null, null, *, *)= true + * ObjectUtils.anyNull(null)= true + * ObjectUtils.anyNull(null, null) = true + * ObjectUtils.anyNull()= false + * ObjectUtils.anyNull((Object[]) null) = false + * + * + * @param values the values to test, may be {@code null} or empty + * @return {@code true} if there is at least one null value in the array, + * {@code false} if all values in the array are not {@code null}s. + * If the array is {@code null} or empty {@code fatolse} is also returned. --- End diff -- `fatolse` -> `false` ! ---
[GitHub] commons-lang pull request #357: Proposal for LANG-1421
GitHub user sparsick opened a pull request: https://github.com/apache/commons-lang/pull/357 Proposal for LANG-1421 - replace test annotation and assertions in ObjectUtilsTest with junit5 - implementation of `allNull` and `anyNull` You can merge this pull request into a Git repository by running: $ git pull https://github.com/sparsick/commons-lang 1421-anyNull Alternatively you can review and apply these changes as the patch at: https://github.com/apache/commons-lang/pull/357.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #357 commit 3c133c202cc457318f2992ef4d7c5a316d0a017c Author: sparsick Date: 2018-09-21T13:09:46Z move test to junit 5 Co-authored-by: Georg Berky commit 38152d9a52d3f62a317ee5ffd1e5fce3cf50bc6e Author: sparsick Date: 2018-09-21T13:25:25Z LANG-1421: add method anyNull to ObjectUtils Co-authored-by: Georg Berky commit 8e51c8c4e5435e6efaa9f8447e2cf6987b5c4f8a Author: sparsick Date: 2018-09-21T13:30:54Z LANG-1421: add javadoc for anyNull in ObjectUtils Co-authored-by: Georg Berky commit c0c6d7d2fef49a5b8d3b490aa666fa196ff11733 Author: sparsick Date: 2018-09-21T13:42:53Z LANG-1421: add allNull in ObjectUtils with javadoc Co-authored-by: Georg Berky ---