Skip to content
Permalink
Browse files
cache constrained-ness of executable parameters/return values
  • Loading branch information
mbenson committed Feb 8, 2019
1 parent da53873 commit c39044853929ece203b681ada116bffb2af14536
Showing 1 changed file with 6 additions and 2 deletions.
@@ -33,6 +33,8 @@
private final ReturnValueD<SELF, E> returnValue;
private final List<ParameterD<SELF>> parameters;
private final CrossParameterD<SELF, E> crossParameter;
private final boolean parametersAreConstrained;
private final boolean returnValueIsConstrained;

@SuppressWarnings("unchecked")
protected ExecutableD(R reader, BeanD<?> parent) {
@@ -43,6 +45,8 @@ protected ExecutableD(R reader, BeanD<?> parent) {
returnValue = reader.getReturnValueDescriptor((SELF) this);
parameters = reader.getParameterDescriptors((SELF) this);
crossParameter = reader.getCrossParameterDescriptor((SELF) this);
parametersAreConstrained = parameters.stream().anyMatch(DescriptorManager::isConstrained) || crossParameter.hasConstraints();
returnValueIsConstrained = DescriptorManager.isConstrained(returnValue);
}

@Override
@@ -68,11 +72,11 @@ public final ReturnValueDescriptor getReturnValueDescriptor() {

@Override
public final boolean hasConstrainedParameters() {
return parameters.stream().anyMatch(DescriptorManager::isConstrained) || getCrossParameterDescriptor().hasConstraints();
return parametersAreConstrained;
}

@Override
public final boolean hasConstrainedReturnValue() {
return DescriptorManager.isConstrained(returnValue);
return returnValueIsConstrained;
}
}

0 comments on commit c390448

Please sign in to comment.