From 3ecab4a48e0057d79e709ddecc87d6a04a0052c5 Mon Sep 17 00:00:00 2001 From: Boni Garcia Date: Thu, 26 Oct 2023 15:37:14 +0200 Subject: [PATCH] Use of Options.ofNullable in anntotation reader logic (#410) --- .../java/io/github/bonigarcia/seljup/AnnotationsReader.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/github/bonigarcia/seljup/AnnotationsReader.java b/src/main/java/io/github/bonigarcia/seljup/AnnotationsReader.java index 335e9a91..b38fb876 100644 --- a/src/main/java/io/github/bonigarcia/seljup/AnnotationsReader.java +++ b/src/main/java/io/github/bonigarcia/seljup/AnnotationsReader.java @@ -20,6 +20,7 @@ import static java.util.Arrays.asList; import static java.util.Optional.empty; import static java.util.Optional.of; +import static java.util.Optional.ofNullable; import static org.slf4j.LoggerFactory.getLogger; import java.lang.annotation.Annotation; @@ -188,9 +189,9 @@ private static Optional getField( || annotatedType.isAssignableFrom(field.getType()))) { field.setAccessible(true); if (annotatedType != null) { - return of(annotatedType.cast(field.get(object))); + return ofNullable(annotatedType.cast(field.get(object))); } - return (Optional) of(field.get(object)); + return (Optional) ofNullable(field.get(object)); } } return empty();