Spec-Zone .ru
спецификации, руководства, описания, API


javax.validation
Интерфейс ConstraintValidatorContext


public interface ConstraintValidatorContext

Обеспечьте контекстные данные и работу, применяя данный ограничительный блок проверки допустимости. По крайней мере один ConstraintViolation должен быть определен (любой значение по умолчанию один, если значение по умолчанию ConstraintViolation отключается, пользовательский).

Автор:
Эммануэль Бернард

Вложенная Сводка Класса
static interface ConstraintValidatorContext.ConstraintViolationBuilder
          ConstraintViolation разработчик, позволяющий дополнительно связать отчет нарушения к sub пути.
 
Сводка метода
 ConstraintValidatorContext.ConstraintViolationBuilder buildConstraintViolationWithTemplate(java.lang.String messageTemplate)
          Возвратите ограничительного разработчика нарушения, создающего отчет нарушения, позволяющий дополнительно связать это к sub пути.
 void disableDefaultConstraintViolation()
          Отключите значение по умолчанию ConstraintViolation объектная генерация (который использует шаблон сообщения, объявленный на ограничении).
 java.lang.String getDefaultConstraintMessageTemplate()
           
 

Деталь метода

disableDefaultConstraintViolation

void disableDefaultConstraintViolation()
Отключите значение по умолчанию ConstraintViolation объектная генерация (который использует шаблон сообщения, объявленный на ограничении). Полезный, чтобы установить различное сообщение нарушения или генерировать a ConstraintViolation основанный на различном свойстве.


getDefaultConstraintMessageTemplate

java.lang.String getDefaultConstraintMessageTemplate()
Возвраты:
ток неинтерполированное сообщение значения по умолчанию.

buildConstraintViolationWithTemplate

ConstraintValidatorContext.ConstraintViolationBuilder buildConstraintViolationWithTemplate(java.lang.String messageTemplate)
Возвратите ограничительного разработчика нарушения, создающего отчет нарушения, позволяющий дополнительно связать это к sub пути. Сообщение нарушения будет интерполировано.

Создать ConstraintViolation, нужно вызвать любой #addConstraintViolation () методы, доступные в одном из интерфейсов быстрого API. Если другой метод вызывают после #addConstraintViolation () на ConstraintViolationBuilder или любой из его связанных вложенных интерфейсов IllegalStateException повышается.

Если isValid returns false, a ConstraintViolation object will be built per ConstraintViolation report including the default one (unless disableDefaultConstraintViolation() has been called).

ConstraintViolation objects generated from such a call contain the same contextual information (root bean, path and so on) unless the path has been overriden.

To create a different ConstraintViolation, a new constraint violation builder has to be retrieved from ConstraintValidatorContext Here are a few usage examples:

 // create new violation report with the default path the constraint is located on
 context.buildConstraintViolationWithTemplate( "way too long" )
             .addConstraintViolation();

 // create new violation report in the "street" subnode of the default path
 //the constraint is located on
 context.buildConstraintViolationWithTemplate( "way too long" )
              .addNode( "street" )
              .addConstraintViolation();

 //create new violation report in the "addresses["home"].city.name" subnode
 //of the default path the constraint is located on
 context.buildConstraintViolationWithTemplate( "this detail is wrong" )
              .addNode( "addresses" )
              .addNode( "country" )
                  .inIterable().atKey( "home" )
              .addNode( "name" )
              .addConstraintViolation();
 
 

Parameters:
messageTemplate - new uninterpolated constraint message.
Returns:
Returns an constraint violation builder


Представьте ошибку или функцию

Copyright © 2009-2011, Oracle Corporation and/or its affiliates. All Rights Reserved. Use is subject to license terms.

Generated on 10-February-2011 12:41

free hit counter