Skip to content
Permalink
Browse files
avoid XML-based constraint validator mapping provider if noop
  • Loading branch information
mbenson committed Oct 16, 2018
1 parent 83b0518 commit 4bfbc97f61da7bc96a5ab7ebea7e0ffe8d98f8ae
Showing 1 changed file with 5 additions and 1 deletion.
@@ -21,6 +21,7 @@
import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

@@ -60,7 +61,7 @@ public void process(ConfigurationState configurationState,
}
for (final InputStream xmlStream : configurationState.getMappingStreams()) {
final ConstraintMappingsType mapping = parseXmlMappings(xmlStream);
addValidatorMappingProvider.accept(toMappingProvider(mapping));
Optional.of(mapping).map(this::toMappingProvider).ifPresent(addValidatorMappingProvider);
new XmlBuilder(mapping).forBeans().forEach(addBuilder::accept);
}
}
@@ -85,6 +86,9 @@ private ConstraintMappingsType parseXmlMappings(final InputStream in) {
}

private ValidatorMappingProvider toMappingProvider(ConstraintMappingsType mapping) {
if (mapping.getConstraintDefinition().isEmpty()) {
return null;
}
final Map<Class<? extends Annotation>, ValidatedByType> validatorMappings = new HashMap<>();

for (ConstraintDefinitionType constraintDefinition : mapping.getConstraintDefinition()) {

0 comments on commit 4bfbc97

Please sign in to comment.