private void passViolations ( ConstraintValidatorContext context , Set < ConstraintViolation < Object > > source ) { for ( final ConstraintViolation < Object > violation : source ) { final Iterator < Node > nodeIter = violation . getPropertyPath ( ) . iterator ( ) ; final ConstraintViolationBuilder builder = context . buildConstraintViolationWithTemplate ( violation . getMessageTemplate ( ) ) ; ConstraintValidatorContext nodeContext ; if ( nodeIter . hasNext ( ) ) { StringBuilder sb = new StringBuilder ( nodeIter . next ( ) . getName ( ) ) ; if ( supportsConstraintComposition ) { while ( nodeIter . hasNext ( ) ) { sb . append ( ' ' ) . append ( nodeIter . next ( ) ) ; } } builder . addNode ( sb . toString ( ) ) . addConstraintViolation ( ) ; } else { builder . addConstraintViolation ( ) ; } } }
Pass the given violations to the given context . This method will skip violations that have a property path depth greater than 1 .