From 7b0a775e6b0be04c2d7ba8ce078d656fa8ca931e Mon Sep 17 00:00:00 2001 From: Sashir Estela Date: Sat, 23 Mar 2024 01:07:18 +0000 Subject: [PATCH] Fixing Sonar code smells --- .../sashirestela/cleverclient/support/ReturnType.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/io/github/sashirestela/cleverclient/support/ReturnType.java b/src/main/java/io/github/sashirestela/cleverclient/support/ReturnType.java index 30dbb9c..77736ec 100644 --- a/src/main/java/io/github/sashirestela/cleverclient/support/ReturnType.java +++ b/src/main/java/io/github/sashirestela/cleverclient/support/ReturnType.java @@ -56,22 +56,19 @@ private void setClassByEventIfExists(Method method) { Arrays.stream(annotations) .map(a -> a.annotationType().getDeclaredAnnotation(StreamType.List.class).value()) .findFirst() - .get()); + .orElse(null)); } else if (isAnnotationPresent(annotations, StreamType.class)) { this.classByEvent = calculateClassByEvent( new StreamType[] { Arrays.stream(annotations) .map(a -> a.annotationType().getDeclaredAnnotation(StreamType.class)) .findFirst() - .get() }); + .orElse(null) }); } } } private boolean isAnnotationPresent(Annotation[] annotations, Class clazz) { - return Arrays.stream(annotations) - .filter(a -> a.annotationType().isAnnotationPresent(clazz)) - .findFirst() - .isPresent(); + return Arrays.stream(annotations).anyMatch(a -> a.annotationType().isAnnotationPresent(clazz)); } private Map> calculateClassByEvent(StreamType[] streamTypeList) {