Skip to content

Commit

Permalink
Evaluate getter for optional annotation if field exists (references l…
Browse files Browse the repository at this point in the history
  • Loading branch information
derKrischan committed Dec 8, 2019
1 parent 530151d commit b41efdf
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ private static boolean hasAtLeastOneBeanProperty(Class<?> clazz) {

private static boolean isOptionalProperty(Class beanClass, PropertyDescriptor beanProp) {
Field field = getField(beanClass, beanProp.getName());
return field != null ? field.getAnnotationsByType(Optional.class).length > 0 : beanProp.getReadMethod().getAnnotationsByType(Optional.class).length > 0;
return field != null
? field.getAnnotationsByType(Optional.class).length > 0
|| beanProp.getReadMethod().getAnnotationsByType(Optional.class).length > 0
: beanProp.getReadMethod().getAnnotationsByType(Optional.class).length > 0;
}

private static Field getField(Class beanClass, String fieldName) {
Expand Down

0 comments on commit b41efdf

Please sign in to comment.