// if we only have one mapping we can return the context of just this mapping
if ( programmaticMappings.size() == 1 ) {
return ( (DefaultConstraintMapping) programmaticMappings.iterator().next() ).getContext();
}
ConstraintMappingContext mergedContext = new ConstraintMappingContext();
for ( ConstraintMapping mapping : programmaticMappings ) {
ConstraintMappingContext context = ( (DefaultConstraintMapping) mapping ).getContext();
mergedContext.getAnnotationProcessingOptions().merge( context.getAnnotationProcessingOptions() );
for ( Set<ConfiguredConstraint<?, BeanConstraintLocation>> propertyConstraints : context.getConstraintConfig()
.values() ) {
for ( ConfiguredConstraint<?, BeanConstraintLocation> constraint : propertyConstraints ) {
mergedContext.addConstraintConfig( constraint );
}
}
for ( Set<BeanConstraintLocation> beanConstraintLocations : context.getCascadeConfig().values() ) {
for ( BeanConstraintLocation beanLocation : beanConstraintLocations ) {
mergedContext.addCascadeConfig( beanLocation );
}
}
for ( Set<ConfiguredConstraint<?, ExecutableConstraintLocation>> methodConstraints : context.getMethodConstraintConfig()
.values() ) {
for ( ConfiguredConstraint<?, ExecutableConstraintLocation> methodConstraint : methodConstraints ) {
mergedContext.addMethodConstraintConfig( methodConstraint );
}
}
for ( Set<ExecutableConstraintLocation> cascadedMethodConstraints : context.getMethodCascadeConfig()
.values() ) {
for ( ExecutableConstraintLocation methodCascade : cascadedMethodConstraints ) {
mergedContext.addMethodCascadeConfig( methodCascade );
}
}