diff --git a/src/main/java/org/springframework/hateoas/mediatype/PropertyUtils.java b/src/main/java/org/springframework/hateoas/mediatype/PropertyUtils.java index 85aedfef..e3b1676f 100644 --- a/src/main/java/org/springframework/hateoas/mediatype/PropertyUtils.java +++ b/src/main/java/org/springframework/hateoas/mediatype/PropertyUtils.java @@ -539,7 +539,7 @@ public class PropertyUtils { private static class Jsr303AwarePropertyMetadata extends DefaultPropertyMetadata { private static final Optional> LENGTH_ANNOTATION; - private static final Class URL_ANNOTATION, RANGE_ANNOTATION; + private static final @Nullable Class URL_ANNOTATION, RANGE_ANNOTATION; private static final Map, String> TYPE_MAP; static { @@ -609,10 +609,13 @@ public class PropertyUtils { @Override public Long getMin() { - Optional attribute = getAnnotationAttribute(RANGE_ANNOTATION, "min", Long.class); + if (RANGE_ANNOTATION != null) { - if (attribute.isPresent()) { - return attribute.get(); + Optional attribute = getAnnotationAttribute(RANGE_ANNOTATION, "min", Long.class); + + if (attribute.isPresent()) { + return attribute.get(); + } } return getAnnotationAttribute(Min.class, "value", Long.class).orElse(null); @@ -626,10 +629,13 @@ public class PropertyUtils { @Override public Long getMax() { - Optional attribute = getAnnotationAttribute(RANGE_ANNOTATION, "max", Long.class); + if (RANGE_ANNOTATION != null) { - if (attribute.isPresent()) { - return attribute.get(); + Optional attribute = getAnnotationAttribute(RANGE_ANNOTATION, "max", Long.class); + + if (attribute.isPresent()) { + return attribute.get(); + } } return getAnnotationAttribute(Max.class, "value", Long.class).orElse(null);