Top Description Inners Fields Constructors Methods
org.hibernate.validator.internal.engine

public Class MethodValidationConfiguration

extends Object
Class Inheritance
Static Imports
org.hibernate.validator.internal.util.CollectionHelper.newHashSet

These properties modify the behavior of the Validator with respect to the Jakarta Bean Validation specification section 5.6.5. In particular:
"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."
Authors
Chris Beckey <[email protected]>, Guillaume Smet

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean
private Set<MethodConfigurationRule>

Constructor Summary

AccessConstructor and Description
private
MethodValidationConfiguration(boolean allowOverridingMethodAlterParameterConstraint, boolean allowMultipleCascadedValidationOnReturnValues, boolean allowParallelMethodsDefineParameterConstraints)

Method Summary

Modifier and TypeMethod and Description
private static Set<MethodConfigurationRule>
buildConfiguredRuleSet(boolean allowOverridingMethodAlterParameterConstraint, boolean allowMultipleCascadedValidationOnReturnValues, boolean allowParallelMethodsDefineParameterConstraints)

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public Set<MethodConfigurationRule>

Returns:

a set of method configuration rules based on this configuration state
getConfiguredRuleSet
()

Return an unmodifiable Set of MethodConfigurationRule that are to be enforced based on the configuration.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean

Returns:

true if more than one return value within a class hierarchy can be marked for cascaded validation, false otherwise.
isAllowMultipleCascadedValidationOnReturnValues
()

public boolean

Returns:

true if more than one return value within a class hierarchy can be marked for cascaded validation, false otherwise.
isAllowOverridingMethodAlterParameterConstraint
()

public boolean

Returns:

true if constraints on methods in parallel class hierarchy are allowed, false otherwise.
isAllowParallelMethodsDefineParameterConstraints
()

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

allowMultipleCascadedValidationOnReturnValuesback to summary
private boolean allowMultipleCascadedValidationOnReturnValues
allowOverridingMethodAlterParameterConstraintback to summary
private boolean allowOverridingMethodAlterParameterConstraint
allowParallelMethodsDefineParameterConstraintsback to summary
private boolean allowParallelMethodsDefineParameterConstraints
configuredRuleSetback to summary
private Set<MethodConfigurationRule> configuredRuleSet
Annotations
@Immutable

Constructor Detail

MethodValidationConfigurationback to summary
private MethodValidationConfiguration(boolean allowOverridingMethodAlterParameterConstraint, boolean allowMultipleCascadedValidationOnReturnValues, boolean allowParallelMethodsDefineParameterConstraints)

Method Detail

buildConfiguredRuleSetback to summary
private static Set<MethodConfigurationRule> buildConfiguredRuleSet(boolean allowOverridingMethodAlterParameterConstraint, boolean allowMultipleCascadedValidationOnReturnValues, boolean allowParallelMethodsDefineParameterConstraints)
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getConfiguredRuleSetback to summary
public Set<MethodConfigurationRule> getConfiguredRuleSet()

Return an unmodifiable Set of MethodConfigurationRule that are to be enforced based on the configuration.

Returns:Set<MethodConfigurationRule>

a set of method configuration rules based on this configuration state

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
isAllowMultipleCascadedValidationOnReturnValuesback to summary
public boolean isAllowMultipleCascadedValidationOnReturnValues()
Returns:boolean

true if more than one return value within a class hierarchy can be marked for cascaded validation, false otherwise.

isAllowOverridingMethodAlterParameterConstraintback to summary
public boolean isAllowOverridingMethodAlterParameterConstraint()
Returns:boolean

true if more than one return value within a class hierarchy can be marked for cascaded validation, false otherwise.

isAllowParallelMethodsDefineParameterConstraintsback to summary
public boolean isAllowParallelMethodsDefineParameterConstraints()
Returns:boolean

true if constraints on methods in parallel class hierarchy are allowed, false otherwise.

org.hibernate.validator.internal.engine back to summary

public Class MethodValidationConfiguration.Builder

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.validator.internal.engine.MethodValidationConfiguration.Builder

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public MethodValidationConfiguration.Builder

Returns:

this following the chaining method pattern
allowMultipleCascadedValidationOnReturnValues
(boolean
flag determining whether validation will allow multiple cascaded validation on return values.
allow
)

Define whether more than one constraint on a return value may be marked for cascading validation are allowed.

public MethodValidationConfiguration.Builder

Returns:

this following the chaining method pattern
allowOverridingMethodAlterParameterConstraint
(boolean
flag determining whether validation will allow overriding to alter parameter constraints.
allow
)

Define whether overriding methods that override constraints should throw a ConstraintDefinitionException.

public MethodValidationConfiguration.Builder

Returns:

this following the chaining method pattern
allowParallelMethodsDefineParameterConstraints
(boolean
flag determining whether validation will allow parameter constraints in parallel hierarchies
allow
)

Define whether parallel methods that define constraints should throw a ConstraintDefinitionException.

public MethodValidationConfiguration
public boolean
public boolean
public boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowMultipleCascadedValidationOnReturnValuesback to summary
private boolean allowMultipleCascadedValidationOnReturnValues
allowOverridingMethodAlterParameterConstraintback to summary
private boolean allowOverridingMethodAlterParameterConstraint
allowParallelMethodsDefineParameterConstraintsback to summary
private boolean allowParallelMethodsDefineParameterConstraints

Constructor Detail

Builderback to summary
public Builder()
Builderback to summary
public Builder(MethodValidationConfiguration template)

Method Detail

allowMultipleCascadedValidationOnReturnValuesback to summary
public MethodValidationConfiguration.Builder allowMultipleCascadedValidationOnReturnValues(boolean allow)

Define whether more than one constraint on a return value may be marked for cascading validation are allowed. The default value is 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."

Parameters
allow:boolean

flag determining whether validation will allow multiple cascaded validation on return values.

Returns:MethodValidationConfiguration.Builder

this following the chaining method pattern

allowOverridingMethodAlterParameterConstraintback to summary
public MethodValidationConfiguration.Builder allowOverridingMethodAlterParameterConstraint(boolean allow)

Define whether overriding methods that override constraints should throw a ConstraintDefinitionException. The default value is false, i.e. do not allow. See Section 5.6.5 of the Jakarta Bean Validation 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."
Parameters
allow:boolean

flag determining whether validation will allow overriding to alter parameter constraints.

Returns:MethodValidationConfiguration.Builder

this following the chaining method pattern

allowParallelMethodsDefineParameterConstraintsback to summary
public MethodValidationConfiguration.Builder allowParallelMethodsDefineParameterConstraints(boolean allow)

Define whether parallel methods that define constraints should throw a ConstraintDefinitionException. The default value is false, i.e. do not allow. See Section 5.6.5 of the Jakarta Bean Validation 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."

Parameters
allow:boolean

flag determining whether validation will allow parameter constraints in parallel hierarchies

Returns:MethodValidationConfiguration.Builder

this following the chaining method pattern

buildback to summary
public MethodValidationConfiguration build()
isAllowMultipleCascadedValidationOnReturnValuesback to summary
public boolean isAllowMultipleCascadedValidationOnReturnValues()
isAllowOverridingMethodAlterParameterConstraintback to summary
public boolean isAllowOverridingMethodAlterParameterConstraint()
isAllowParallelMethodsDefineParameterConstraintsback to summary
public boolean isAllowParallelMethodsDefineParameterConstraints()