public class MethodValidationConfiguration extends Object
"Out of the box, a conforming Bean Validation provider must throw a ConstraintDeclarationException when discovering that any of these rules are violated. In addition providers may implement alternative, potentially more liberal, approaches for handling constrained methods in inheritance hierarchies. Possible means for activating such alternative behavior include provider-specific configuration properties or annotations. Note that client code relying on such alternative behavior is not portable between Bean Validation providers."
Constructor and Description |
---|
MethodValidationConfiguration() |
Modifier and Type | Method and Description |
---|---|
MethodValidationConfiguration |
allowMultipleCascadedValidationOnReturnValues(boolean allow)
Define whether more than one constraint on a return value may be marked for cascading validation are allowed.
|
MethodValidationConfiguration |
allowOverridingMethodAlterParameterConstraint(boolean allow)
Define whether overriding methods that override constraints should throw a
ConstraintDefinitionException . |
MethodValidationConfiguration |
allowParallelMethodsDefineParameterConstraints(boolean allow)
Define whether parallel methods that define constraints should throw a
ConstraintDefinitionException . |
Set<MethodConfigurationRule> |
getConfiguredRuleSet()
Return an unmodifiable Set of MethodConfigurationRule that are to be
enforced based on the configuration.
|
boolean |
isAllowMultipleCascadedValidationOnReturnValues() |
boolean |
isAllowOverridingMethodAlterParameterConstraint() |
boolean |
isAllowParallelMethodsDefineParameterConstraints() |
public MethodValidationConfiguration allowOverridingMethodAlterParameterConstraint(boolean allow)
ConstraintDefinitionException
.
The default value is false
, i.e. do not allow.
See Section 4.5.5 of JSR-349 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."
allow
- flag determining whether validation will allow overriding to alter parameter constraints.this
following the chaining method patternpublic MethodValidationConfiguration allowMultipleCascadedValidationOnReturnValues(boolean allow)
false
, i.e. do not allow.
"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."allow
- flag determining whether validation will allow multiple cascaded validation on return values.this
following the chaining method patternpublic MethodValidationConfiguration allowParallelMethodsDefineParameterConstraints(boolean allow)
ConstraintDefinitionException
. The
default value is false
, i.e. do not allow.
See Section 4.5.5 of JSR-349 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."allow
- flag determining whether validation will allow parameter constraints in parallel hierarchiesthis
following the chaining method patternpublic boolean isAllowOverridingMethodAlterParameterConstraint()
true
if more than one return value within a class hierarchy can be marked for cascaded
validation, false
otherwise.public boolean isAllowMultipleCascadedValidationOnReturnValues()
true
if more than one return value within a class hierarchy can be marked for cascaded
validation, false
otherwise.public boolean isAllowParallelMethodsDefineParameterConstraints()
true
if constraints on methods in parallel class hierarchy are allowed, false
otherwise.public Set<MethodConfigurationRule> getConfiguredRuleSet()
Copyright © 2017 JBoss by Red Hat. All rights reserved.