You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/08/21 15:07:43 UTC

[commons-lang] 02/10: Use Stream.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git

commit f9484a4b961b0009d175bc34afca783b29aa68e7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Aug 21 11:04:28 2022 -0400

    Use Stream.
---
 src/main/java/org/apache/commons/lang3/AnnotationUtils.java | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/lang3/AnnotationUtils.java b/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
index a56ee6e07..09450c2ed 100644
--- a/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
+++ b/src/main/java/org/apache/commons/lang3/AnnotationUtils.java
@@ -69,12 +69,11 @@ public class AnnotationUtils {
          */
         @Override
         protected String getShortClassName(final Class<?> cls) {
-            for (final Class<?> iface : ClassUtils.getAllInterfaces(cls)) {
-                if (Annotation.class.isAssignableFrom(iface)) {
-                    return "@" + iface.getName();
-                }
-            }
-            return StringUtils.EMPTY;
+            // formatter:off
+            return ClassUtils.getAllInterfaces(cls).stream().filter(Annotation.class::isAssignableFrom).findFirst()
+                .map(iface -> "@" + iface.getName())
+                .orElse(StringUtils.EMPTY);
+            // formatter:on
         }
 
         /**