All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.validator.HibernateValidatorContext Maven / Gradle / Ivy

/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or .
 */

package org.hibernate.validator;

import javax.validation.ClockProvider;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
import javax.validation.ParameterNameProvider;
import javax.validation.TraversableResolver;
import javax.validation.ValidatorContext;
import javax.validation.valueextraction.ValueExtractor;

/**
 * Represents a Hibernate Validator specific context that is used to create
 * {@link javax.validation.Validator} instances. Adds additional configuration options to those
 * provided by {@link ValidatorContext}.
 *
 * @author Emmanuel Bernard
 * @author Kevin Pollet <[email protected]> (C) 2011 SERLI
 * @author Gunnar Morling
 * @author Chris Beckey <[email protected]>
 */
public interface HibernateValidatorContext extends ValidatorContext {

	@Override
	HibernateValidatorContext messageInterpolator(MessageInterpolator messageInterpolator);

	@Override
	HibernateValidatorContext traversableResolver(TraversableResolver traversableResolver);

	@Override
	HibernateValidatorContext constraintValidatorFactory(ConstraintValidatorFactory factory);

	/**
	 * @since 5.2
	 */
	@Override
	HibernateValidatorContext parameterNameProvider(ParameterNameProvider parameterNameProvider);

	/**
	 * @since 6.0
	 */
	@Override
	HibernateValidatorContext clockProvider(ClockProvider clockProvider);

	/**
	 * @since 6.0
	 */
	@Override
	HibernateValidatorContext addValueExtractor(ValueExtractor extractor);

	/**
	 * En- or disables the fail fast mode. When fail fast is enabled the validation
	 * will stop on the first constraint violation detected.
	 *
	 * @param failFast {@code true} to enable fail fast, {@code false} otherwise.
	 *
	 * @return {@code this} following the chaining method pattern
	 */
	HibernateValidatorContext failFast(boolean failFast);

	/**
	 * Define whether overriding methods that override constraints should throw a {@code ConstraintDefinitionException}.
	 * The default value is {@code false}, i.e. do not allow.
	 * 

* See Section 4.5.5 of the JSR 380 specification, specifically *

	 * "In sub types (be it sub classes/interfaces or interface implementations), no parameter constraints may
	 * be declared on overridden or implemented methods, nor may parameters be marked for cascaded validation.
	 * This would pose a strengthening of preconditions to be fulfilled by the caller."
	 * 
* * @param allow flag determining whether validation will allow overriding to alter parameter constraints. * * @return {@code this} following the chaining method pattern * * @since 5.3 */ HibernateValidatorContext allowOverridingMethodAlterParameterConstraint(boolean allow); /** * Define whether more than one constraint on a return value may be marked for cascading validation are allowed. * The default value is {@code false}, i.e. do not allow. *

* See Section 4.5.5 of the JSR 380 specification, specifically *

	 * "One must not mark a method return value for cascaded validation more than once in a line of a class hierarchy.
	 * In other words, overriding methods on sub types (be it sub classes/interfaces or interface implementations)
	 * cannot mark the return value for cascaded validation if the return value has already been marked on the
	 * overridden method of the super type or interface."
	 * 
* * @param allow flag determining whether validation will allow multiple cascaded validation on return values. * * @return {@code this} following the chaining method pattern * * @since 5.3 */ HibernateValidatorContext allowMultipleCascadedValidationOnReturnValues(boolean allow); /** * Define whether parallel methods that define constraints should throw a {@code ConstraintDefinitionException}. The * default value is {@code false}, i.e. do not allow. *

* See Section 4.5.5 of the JSR 380 specification, specifically *

	 * "If a sub type overrides/implements a method originally defined in several parallel types of the hierarchy
	 * (e.g. two interfaces not extending each other, or a class and an interface not implemented by said class),
	 * no parameter constraints may be declared for that method at all nor parameters be marked for cascaded validation.
	 * This again is to avoid an unexpected strengthening of preconditions to be fulfilled by the caller."
	 * 
* * @param allow flag determining whether validation will allow parameter constraints in parallel hierarchies * * @return {@code this} following the chaining method pattern * * @since 5.3 */ HibernateValidatorContext allowParallelMethodsDefineParameterConstraints(boolean allow); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy