garydgregory commented on a change in pull request #782:
URL: https://github.com/apache/commons-lang/pull/782#discussion_r694877354



##########
File path: src/main/java/org/apache/commons/lang3/ObjectUtils.java
##########
@@ -634,6 +634,35 @@ public static boolean equals(final Object object1, final 
Object object2) {
         return object1.equals(object2);
     }
 
+    /**
+     * <p>Compares given {@code object} to a vararg of {@code 
searchObjects}</p>
+     *
+     * <pre>
+     * ObjectUtils.equalsAny(null)                                      = false
+     * ObjectUtils.equalsAny(null, null, null)                          = true
+     * ObjectUtils.equalsAny("", "")                                    = true
+     * ObjectUtils.equalsAny(Boolean.TRUE, null)                        = false
+     * ObjectUtils.equalsAny(Boolean.TRUE, "true")                      = false
+     * ObjectUtils.equalsAny(Boolean.TRUE, Boolean.TRUE)                = true
+     * ObjectUtils.equalsAny(Boolean.TRUE, Boolean.FALSE, Boolean.TRUE) = true
+     * </pre>
+     *
+     * @param object to compare, may be {@code null}
+     * @param searchObjects a vararg of objects, may be {@code null}.
+     * @return {@code true} if {@code object} is equal to any of the {@code 
searchObjects}.
+     */
+    public static boolean equalsAny(final Object object, final Object... 
searchObjects) {
+        if (ArrayUtils.isEmpty(searchObjects)) {

Review comment:
       Or just `searchObjects== null ? false : 
Stream.of(searchObjects).anyMatch(e -> Objects.equals(object, e));`
   -1 anyway since this duplicated the functionality in 
`ArrayUtils.contains(Object[], Object)`




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to