Skip to content
Permalink
Browse files
efficiency
  • Loading branch information
mbenson committed Oct 17, 2018
1 parent 796a2ca commit 6cb3093068bab8f70cdeb4d370f7318c817fffcf
Showing 1 changed file with 10 additions and 7 deletions.
@@ -76,16 +76,19 @@ public <T> BeanDescriptor getBeanDescriptor(Class<T> beanClass) {
if (beanDescriptors.containsKey(beanClass)) {
return beanDescriptors.get(beanClass);
}
final MetadataBuilder.ForBean<T> builder =
knownUnconstrainedTypes.contains(beanClass) ? EmptyBuilder.instance().forBean() : builder(beanClass);
final boolean constrained = !knownUnconstrainedTypes.contains(beanClass);
final MetadataBuilder.ForBean<T> builder = constrained ? builder(beanClass) : EmptyBuilder.instance().forBean();
final BeanD<T> beanD = new BeanD<>(new MetadataReader(validatorFactory, beanClass).forBean(builder));

if (beanD.isBeanConstrained() || !(beanD.getConstrainedConstructors().isEmpty()
&& beanD.getConstrainedMethods(MethodType.GETTER, MethodType.NON_GETTER).isEmpty())) {
@SuppressWarnings("unchecked")
final BeanD<T> result =
if (constrained) {
// if not previously known to be unconstrained, check:
if (beanD.isBeanConstrained() || !(beanD.getConstrainedConstructors().isEmpty()
&& beanD.getConstrainedMethods(MethodType.GETTER, MethodType.NON_GETTER).isEmpty())) {
@SuppressWarnings("unchecked")
final BeanD<T> result =
Optional.ofNullable((BeanD<T>) beanDescriptors.putIfAbsent(beanClass, beanD)).orElse(beanD);
return result;
return result;
}
}
knownUnconstrainedTypes.add(beanClass);
return beanD;

0 comments on commit 6cb3093

Please sign in to comment.