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) {