Skip to content

Commit

Permalink
Use of Options.ofNullable in anntotation reader logic (#410)
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Oct 26, 2023
1 parent bf88832 commit 3ecab4a
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -188,9 +189,9 @@ private static <T> Optional<T> 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<T>) of(field.get(object));
return (Optional<T>) ofNullable(field.get(object));
}
}
return empty();
Expand Down

0 comments on commit 3ecab4a

Please sign in to comment.