Class AbstractConfigurationImpl<T extends BaseHibernateValidatorConfiguration<T>>
- All Implemented Interfaces:
Configuration<T>,ConfigurationState,BaseHibernateValidatorConfiguration<T>
- Direct Known Subclasses:
ConfigurationImpl,PredefinedScopeConfigurationImpl
Configuration implementation.- Author:
- Emmanuel Bernard, Hardy Ferentschik, Gunnar Morling, Kevin Pollet <kevin.pollet@serli.com> (C) 2011 SERLI, Chris Beckey <cbeckey@paypal.com>, Guillaume Smet
-
Field Summary
Fields inherited from interface org.hibernate.validator.BaseHibernateValidatorConfiguration
ALLOW_MULTIPLE_CASCADED_VALIDATION_ON_RESULT, ALLOW_PARALLEL_METHODS_DEFINE_PARAMETER_CONSTRAINTS, ALLOW_PARAMETER_CONSTRAINT_OVERRIDE, CONSTRAINT_EXPRESSION_LANGUAGE_FEATURE_LEVEL, CONSTRAINT_MAPPING_CONTRIBUTOR, CONSTRAINT_MAPPING_CONTRIBUTORS, CUSTOM_VIOLATION_EXPRESSION_LANGUAGE_FEATURE_LEVEL, ENABLE_TRAVERSABLE_RESOLVER_RESULT_CACHE, FAIL_FAST, GETTER_PROPERTY_SELECTION_STRATEGY_CLASSNAME, LOCALE_RESOLVER_CLASSNAME, PROPERTY_NODE_NAME_PROVIDER_CLASSNAME, SCRIPT_EVALUATOR_FACTORY_CLASSNAME, SHOW_VALIDATED_VALUE_IN_TRACE_LOGS, TEMPORAL_VALIDATION_TOLERANCE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractConfigurationImpl(ValidationProvider<?> provider) -
Method Summary
Modifier and TypeMethodDescriptionfinal TaddMapping(InputStream stream) final TaddMapping(ConstraintMapping mapping) Adds the specifiedConstraintMappinginstance to the configuration.final TaddProperty(String name, String value) addValueExtractor(ValueExtractor<?> extractor) allowMultipleCascadedValidationOnReturnValues(boolean allow) Define whether more than one constraint on a return value may be marked for cascading validation are allowed.allowOverridingMethodAlterParameterConstraint(boolean allow) Define whether overriding methods that override constraints should throw aConstraintDefinitionException.allowParallelMethodsDefineParameterConstraints(boolean allow) Define whether parallel methods that define constraints should throw aConstraintDefinitionException.beanMetaDataClassNormalizer(BeanMetaDataClassNormalizer beanMetaDataClassNormalizer) final ValidatorFactoryclockProvider(ClockProvider clockProvider) constraintExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel) Allows setting the Expression Language feature level for message interpolation of constraint messages.final TconstraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory) constraintValidatorPayload(Object constraintValidatorPayload) Allows to set a payload which will be passed to the constraint validators.final DefaultConstraintMappingCreates a new constraint mapping which can be used to programmatically configure the constraints for given types.customViolationExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel) Allows setting the Expression Language feature level for message interpolation of custom violation messages.defaultLocale(Locale defaultLocale) Allows setting the default locale used to interpolate the constraint violation messages.final TenableTraversableResolverResultCache(boolean enabled) Define whether the per validation call caching ofTraversableResolverresults is enabled.externalClassLoader(ClassLoader externalClassLoader) Sets the class loader to be used for loading user-provided resources: XML descriptors (META-INF/validation.xmlas well as XML constraint mappings) classes specified by name in XML descriptors (e.g.final TfailFast(boolean failFast) En- or disables the fail fast mode.final MessageInterpolatorfinal ResourceBundleLocatorReturns theResourceBundleLocatorused by thedefault message interpolatorto load user-provided resource bundles.final TraversableResolverSet<ValueExtractor<?>>Returns the defaultValueExtractorimplementations as per the specification.final booleanfinal Set<InputStream>final MessageInterpolatorfinal Set<DefaultConstraintMapping>final booleangetterPropertySelectionStrategy(GetterPropertySelectionStrategy getterPropertySelectionStrategy) Allows to set a getter property selection strategy defining the rules determining if a method is a getter or not.final TraversableResolverSet<ValueExtractor<?>>final Tbooleanbooleanbooleanfinal booleanfinal booleanlocaleResolver(LocaleResolver localeResolver) Allows setting a locale resolver, defining how the locale will be resolved when interpolating the message of a constraint violation.Allows setting the list of the locales supported by this ValidatorFactory.final TmessageInterpolator(MessageInterpolator interpolator) parameterNameProvider(ParameterNameProvider parameterNameProvider) protected abstract booleanpropertyNodeNameProvider(PropertyNodeNameProvider propertyNodeNameProvider) Allows to set a property node name provider, defining how the name of a property node will be resolved when constructing a property path as the one returned byConstraintViolation.getPropertyPath().scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory) Allows to specify a customScriptEvaluatorFactoryresponsible for creatingScriptEvaluators used to evaluate script expressions forScriptAssertandParameterScriptAssertconstraints.showValidatedValuesInTraceLogs(boolean enabled) Allows setting the logging configuration that would include validated values in trace level logs.temporalValidationTolerance(Duration temporalValidationTolerance) Allows to set the acceptable margin of error when comparing date/time in temporal constraints such asPast/PastOrPresentandFuture/FutureOrPresent.protected TthisAsT()final TtraversableResolver(TraversableResolver resolver) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.validator.BaseHibernateValidatorConfiguration
locales
-
Constructor Details
-
AbstractConfigurationImpl
-
AbstractConfigurationImpl
-
-
Method Details
-
ignoreXmlConfiguration
- Specified by:
ignoreXmlConfigurationin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
messageInterpolator
- Specified by:
messageInterpolatorin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
traversableResolver
- Specified by:
traversableResolverin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
enableTraversableResolverResultCache
Description copied from interface:BaseHibernateValidatorConfigurationDefine whether the per validation call caching ofTraversableResolverresults is enabled. The default value istrue, i.e. the caching is enabled.This behavior was initially introduced to cache the
JPATraversableResolverresults but the map lookups it introduces can be counterproductive when theTraversableResolvercalls are very fast.- Specified by:
enableTraversableResolverResultCachein interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
enabled- flag determining whether per validation call caching is enabled forTraversableResolverresults.- Returns:
thisfollowing the chaining method pattern
-
isTraversableResolverResultCacheEnabled
public final boolean isTraversableResolverResultCacheEnabled() -
constraintValidatorFactory
- Specified by:
constraintValidatorFactoryin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
parameterNameProvider
- Specified by:
parameterNameProviderin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
clockProvider
- Specified by:
clockProviderin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
propertyNodeNameProvider
Description copied from interface:BaseHibernateValidatorConfigurationAllows to set a property node name provider, defining how the name of a property node will be resolved when constructing a property path as the one returned byConstraintViolation.getPropertyPath().- Specified by:
propertyNodeNameProviderin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
propertyNodeNameProvider- thePropertyNodeNameProviderto be used- Returns:
thisfollowing the chaining method pattern
-
localeResolver
Description copied from interface:BaseHibernateValidatorConfigurationAllows setting a locale resolver, defining how the locale will be resolved when interpolating the message of a constraint violation.- Specified by:
localeResolverin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
localeResolver- theLocaleResolverto be used- Returns:
thisfollowing the chaining method pattern
-
addValueExtractor
- Specified by:
addValueExtractorin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
addMapping
- Specified by:
addMappingin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
failFast
Description copied from interface:BaseHibernateValidatorConfigurationEn- or disables the fail fast mode. When fail fast is enabled the validation will stop on the first constraint violation detected.- Specified by:
failFastin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
failFast-trueto enable fail fast,falseotherwise.- Returns:
thisfollowing the chaining method pattern
-
allowOverridingMethodAlterParameterConstraint
Description copied from interface:BaseHibernateValidatorConfigurationDefine whether overriding methods that override constraints should throw aConstraintDefinitionException. The default value isfalse, 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."
- Specified by:
allowOverridingMethodAlterParameterConstraintin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
allow- flag determining whether validation will allow overriding to alter parameter constraints.- Returns:
thisfollowing the chaining method pattern
-
isAllowOverridingMethodAlterParameterConstraint
public boolean isAllowOverridingMethodAlterParameterConstraint() -
allowMultipleCascadedValidationOnReturnValues
Description copied from interface:BaseHibernateValidatorConfigurationDefine whether more than one constraint on a return value may be marked for cascading validation are allowed. The default value isfalse, 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."
- Specified by:
allowMultipleCascadedValidationOnReturnValuesin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
allow- flag determining whether validation will allow multiple cascaded validation on return values.- Returns:
thisfollowing the chaining method pattern
-
isAllowMultipleCascadedValidationOnReturnValues
public boolean isAllowMultipleCascadedValidationOnReturnValues() -
allowParallelMethodsDefineParameterConstraints
Description copied from interface:BaseHibernateValidatorConfigurationDefine whether parallel methods that define constraints should throw aConstraintDefinitionException. The default value isfalse, 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."
- Specified by:
allowParallelMethodsDefineParameterConstraintsin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
allow- flag determining whether validation will allow parameter constraints in parallel hierarchies- Returns:
thisfollowing the chaining method pattern
-
scriptEvaluatorFactory
Description copied from interface:BaseHibernateValidatorConfigurationAllows to specify a customScriptEvaluatorFactoryresponsible for creatingScriptEvaluators used to evaluate script expressions forScriptAssertandParameterScriptAssertconstraints.- Specified by:
scriptEvaluatorFactoryin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
scriptEvaluatorFactory- theScriptEvaluatorFactoryto be used- Returns:
thisfollowing the chaining method pattern
-
temporalValidationTolerance
Description copied from interface:BaseHibernateValidatorConfigurationAllows to set the acceptable margin of error when comparing date/time in temporal constraints such asPast/PastOrPresentandFuture/FutureOrPresent.- Specified by:
temporalValidationTolerancein interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
temporalValidationTolerance- the acceptable tolerance- Returns:
thisfollowing the chaining method pattern
-
constraintValidatorPayload
Description copied from interface:BaseHibernateValidatorConfigurationAllows to set a payload which will be passed to the constraint validators. If the method is called multiple times, only the payload passed last will be propagated.- Specified by:
constraintValidatorPayloadin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
constraintValidatorPayload- the payload passed to constraint validators- Returns:
thisfollowing the chaining method pattern
-
getterPropertySelectionStrategy
public T getterPropertySelectionStrategy(GetterPropertySelectionStrategy getterPropertySelectionStrategy) Description copied from interface:BaseHibernateValidatorConfigurationAllows to set a getter property selection strategy defining the rules determining if a method is a getter or not.- Specified by:
getterPropertySelectionStrategyin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
getterPropertySelectionStrategy- theGetterPropertySelectionStrategyto be used- Returns:
thisfollowing the chaining method pattern
-
locales
Description copied from interface:BaseHibernateValidatorConfigurationAllows setting the list of the locales supported by this ValidatorFactory.Can be used for advanced locale resolution and/or to force the initialization of the resource bundles at bootstrap.
If not set, defaults to a singleton containing
Locale.getDefault().- Specified by:
localesin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
defaultLocale
Description copied from interface:BaseHibernateValidatorConfigurationAllows setting the default locale used to interpolate the constraint violation messages.If not set, defaults to the system locale obtained via
Locale.getDefault().- Specified by:
defaultLocalein interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
isAllowParallelMethodsDefineParameterConstraints
public boolean isAllowParallelMethodsDefineParameterConstraints() -
getMethodValidationConfiguration
-
createConstraintMapping
Description copied from interface:BaseHibernateValidatorConfigurationCreates a new constraint mapping which can be used to programmatically configure the constraints for given types. After the mapping has been set up, it must be added to this configuration viaBaseHibernateValidatorConfiguration.addMapping(ConstraintMapping).- Specified by:
createConstraintMappingin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Returns:
- A new constraint mapping.
-
addMapping
Description copied from interface:BaseHibernateValidatorConfigurationAdds the specifiedConstraintMappinginstance to the configuration. Constraints configured inmappingwill be added to the constraints configured via annotations and/or xml.- Specified by:
addMappingin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
mapping-ConstraintMappinginstance containing programmatic configured constraints- Returns:
thisfollowing the chaining method pattern
-
addProperty
- Specified by:
addPropertyin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
externalClassLoader
Description copied from interface:BaseHibernateValidatorConfigurationSets the class loader to be used for loading user-provided resources:- XML descriptors (
META-INF/validation.xmlas well as XML constraint mappings) - classes specified by name in XML descriptors (e.g. custom message interpolators etc.)
- the
ValidationMessagesresource bundle
- Specified by:
externalClassLoaderin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
externalClassLoader- The class loader for loading user-provided resources.- Returns:
thisfollowing the chaining method pattern
- XML descriptors (
-
buildValidatorFactory
- Specified by:
buildValidatorFactoryin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
isIgnoreXmlConfiguration
public final boolean isIgnoreXmlConfiguration()- Specified by:
isIgnoreXmlConfigurationin interfaceConfigurationState
-
getMessageInterpolator
- Specified by:
getMessageInterpolatorin interfaceConfigurationState
-
getMappingStreams
- Specified by:
getMappingStreamsin interfaceConfigurationState
-
getFailFast
public final boolean getFailFast() -
getConstraintValidatorFactory
- Specified by:
getConstraintValidatorFactoryin interfaceConfigurationState
-
getTraversableResolver
- Specified by:
getTraversableResolverin interfaceConfigurationState
-
getBootstrapConfiguration
- Specified by:
getBootstrapConfigurationin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getParameterNameProvider
- Specified by:
getParameterNameProviderin interfaceConfigurationState
-
getClockProvider
- Specified by:
getClockProviderin interfaceConfigurationState
-
getPropertyNodeNameProvider
-
getLocaleResolver
-
getScriptEvaluatorFactory
-
getTemporalValidationTolerance
-
getConstraintValidatorPayload
-
getGetterPropertySelectionStrategy
-
getValueExtractors
- Specified by:
getValueExtractorsin interfaceConfigurationState
-
getProperties
- Specified by:
getPropertiesin interfaceConfigurationState
-
getExternalClassLoader
-
getDefaultMessageInterpolator
- Specified by:
getDefaultMessageInterpolatorin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getDefaultTraversableResolver
- Specified by:
getDefaultTraversableResolverin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getDefaultConstraintValidatorFactory
- Specified by:
getDefaultConstraintValidatorFactoryin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getDefaultResourceBundleLocator
Description copied from interface:BaseHibernateValidatorConfigurationReturns the
ResourceBundleLocatorused by thedefault message interpolatorto load user-provided resource bundles. In conformance with the specification this default locator retrieves the bundle "ValidationMessages".This locator can be used as delegate for custom locators when setting a customized
ResourceBundleMessageInterpolator:HibernateValidatorConfiguration configure = Validation.byProvider(HibernateValidator.class).configure(); ResourceBundleLocator defaultResourceBundleLocator = configure.getDefaultBundleLocator(); ResourceBundleLocator myResourceBundleLocator = new MyResourceBundleLocator(defaultResourceBundleLocator); configure.messageInterpolator( new ResourceBundleMessageInterpolator(myResourceBundleLocator));- Specified by:
getDefaultResourceBundleLocatorin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Returns:
- The default
ResourceBundleLocator. Never null.
-
getDefaultParameterNameProvider
- Specified by:
getDefaultParameterNameProviderin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getDefaultClockProvider
- Specified by:
getDefaultClockProviderin interfaceConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getDefaultValueExtractors
Description copied from interface:BaseHibernateValidatorConfigurationReturns the defaultValueExtractorimplementations as per the specification.- Specified by:
getDefaultValueExtractorsin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Returns:
- the default
ValueExtractorimplementations compliant with the specification
-
beanMetaDataClassNormalizer
- Specified by:
beanMetaDataClassNormalizerin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
-
getBeanMetaDataClassNormalizer
-
constraintExpressionLanguageFeatureLevel
public T constraintExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel) Description copied from interface:BaseHibernateValidatorConfigurationAllows setting the Expression Language feature level for message interpolation of constraint messages.This is the feature level used for messages hardcoded inside the constraint declaration.
If you are creating custom constraint violations, Expression Language support needs to be explicitly enabled and use the safest feature level by default if enabled.
- Specified by:
constraintExpressionLanguageFeatureLevelin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
expressionLanguageFeatureLevel- theExpressionLanguageFeatureLevelto be used- Returns:
thisfollowing the chaining method pattern
-
getConstraintExpressionLanguageFeatureLevel
-
customViolationExpressionLanguageFeatureLevel
public T customViolationExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel) Description copied from interface:BaseHibernateValidatorConfigurationAllows setting the Expression Language feature level for message interpolation of custom violation messages.This is the feature level used for messages of custom violations created by the
ConstraintValidatorContext.- Specified by:
customViolationExpressionLanguageFeatureLevelin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
expressionLanguageFeatureLevel- theExpressionLanguageFeatureLevelto be used- Returns:
thisfollowing the chaining method pattern
-
getCustomViolationExpressionLanguageFeatureLevel
-
showValidatedValuesInTraceLogs
Description copied from interface:BaseHibernateValidatorConfigurationAllows setting the logging configuration that would include validated values in trace level logs.By default, values will not be printed to the logs as they might contain sensitive data.
- Specified by:
showValidatedValuesInTraceLogsin interfaceBaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>- Parameters:
enabled- flag determining whether validated values will be printed out into trace level logs or not.- Returns:
thisfollowing the chaining method pattern
-
getShowValidatedValuesInTraceLogs
public final boolean getShowValidatedValuesInTraceLogs() -
getProgrammaticMappings
-
preloadResourceBundles
protected abstract boolean preloadResourceBundles() -
thisAsT
-