public abstract class AbstractConfigurationImpl<T extends BaseHibernateValidatorConfiguration<T>> extends Object implements BaseHibernateValidatorConfiguration<T>, ConfigurationState
Configuration
implementation.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, TEMPORAL_VALIDATION_TOLERANCE
Modifier | Constructor and Description |
---|---|
protected |
AbstractConfigurationImpl(BootstrapState state) |
protected |
AbstractConfigurationImpl(ValidationProvider<?> provider) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
locales
protected AbstractConfigurationImpl(BootstrapState state)
protected AbstractConfigurationImpl(ValidationProvider<?> provider)
public final T ignoreXmlConfiguration()
ignoreXmlConfiguration
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final T messageInterpolator(MessageInterpolator interpolator)
messageInterpolator
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final T traversableResolver(TraversableResolver resolver)
traversableResolver
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final T enableTraversableResolverResultCache(boolean enabled)
BaseHibernateValidatorConfiguration
TraversableResolver
results is enabled. The default
value is true
, i.e. the caching is enabled.
This behavior was initially introduced to cache the JPATraversableResolver
results but the map lookups it
introduces can be counterproductive when the TraversableResolver
calls are very fast.
enableTraversableResolverResultCache
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
enabled
- flag determining whether per validation call caching is enabled for TraversableResolver
results.this
following the chaining method patternpublic final boolean isTraversableResolverResultCacheEnabled()
public final T constraintValidatorFactory(ConstraintValidatorFactory constraintValidatorFactory)
constraintValidatorFactory
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public T parameterNameProvider(ParameterNameProvider parameterNameProvider)
parameterNameProvider
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public T clockProvider(ClockProvider clockProvider)
clockProvider
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public T propertyNodeNameProvider(PropertyNodeNameProvider propertyNodeNameProvider)
BaseHibernateValidatorConfiguration
ConstraintViolation.getPropertyPath()
.propertyNodeNameProvider
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
propertyNodeNameProvider
- the PropertyNodeNameProvider
to be usedthis
following the chaining method patternpublic T localeResolver(LocaleResolver localeResolver)
BaseHibernateValidatorConfiguration
localeResolver
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
localeResolver
- the LocaleResolver
to be usedthis
following the chaining method patternpublic T addValueExtractor(ValueExtractor<?> extractor)
addValueExtractor
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final T addMapping(InputStream stream)
addMapping
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final T failFast(boolean failFast)
BaseHibernateValidatorConfiguration
failFast
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
failFast
- true
to enable fail fast, false
otherwise.this
following the chaining method patternpublic T allowOverridingMethodAlterParameterConstraint(boolean allow)
BaseHibernateValidatorConfiguration
ConstraintDefinitionException
.
The default value is 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."
allowOverridingMethodAlterParameterConstraint
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
allow
- flag determining whether validation will allow overriding to alter parameter constraints.this
following the chaining method patternpublic boolean isAllowOverridingMethodAlterParameterConstraint()
public T allowMultipleCascadedValidationOnReturnValues(boolean allow)
BaseHibernateValidatorConfiguration
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."
allowMultipleCascadedValidationOnReturnValues
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
allow
- flag determining whether validation will allow multiple cascaded validation on return values.this
following the chaining method patternpublic boolean isAllowMultipleCascadedValidationOnReturnValues()
public T allowParallelMethodsDefineParameterConstraints(boolean allow)
BaseHibernateValidatorConfiguration
ConstraintDefinitionException
. The
default value is 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."
allowParallelMethodsDefineParameterConstraints
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
allow
- flag determining whether validation will allow parameter constraints in parallel hierarchiesthis
following the chaining method patternpublic T scriptEvaluatorFactory(ScriptEvaluatorFactory scriptEvaluatorFactory)
BaseHibernateValidatorConfiguration
ScriptEvaluatorFactory
responsible for creating ScriptEvaluator
s
used to evaluate script expressions for ScriptAssert
and ParameterScriptAssert
constraints.scriptEvaluatorFactory
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
scriptEvaluatorFactory
- the ScriptEvaluatorFactory
to be usedthis
following the chaining method patternpublic T temporalValidationTolerance(Duration temporalValidationTolerance)
BaseHibernateValidatorConfiguration
Past
/PastOrPresent
and Future
/FutureOrPresent
.temporalValidationTolerance
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
temporalValidationTolerance
- the acceptable tolerancethis
following the chaining method patternpublic T constraintValidatorPayload(Object constraintValidatorPayload)
BaseHibernateValidatorConfiguration
constraintValidatorPayload
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
constraintValidatorPayload
- the payload passed to constraint validatorsthis
following the chaining method patternpublic T getterPropertySelectionStrategy(GetterPropertySelectionStrategy getterPropertySelectionStrategy)
BaseHibernateValidatorConfiguration
getterPropertySelectionStrategy
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
getterPropertySelectionStrategy
- the GetterPropertySelectionStrategy
to be usedthis
following the chaining method patternpublic T locales(Set<Locale> locales)
BaseHibernateValidatorConfiguration
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()
.
locales
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
public T defaultLocale(Locale defaultLocale)
BaseHibernateValidatorConfiguration
If not set, defaults to the system locale obtained via Locale.getDefault()
.
defaultLocale
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
public boolean isAllowParallelMethodsDefineParameterConstraints()
public MethodValidationConfiguration getMethodValidationConfiguration()
public final DefaultConstraintMapping createConstraintMapping()
BaseHibernateValidatorConfiguration
BaseHibernateValidatorConfiguration.addMapping(ConstraintMapping)
.createConstraintMapping
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
public final T addMapping(ConstraintMapping mapping)
BaseHibernateValidatorConfiguration
ConstraintMapping
instance to the configuration. Constraints configured in mapping
will be added to the constraints configured via annotations and/or xml.addMapping
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
mapping
- ConstraintMapping
instance containing programmatic configured constraintsthis
following the chaining method patternpublic final T addProperty(String name, String value)
addProperty
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public T externalClassLoader(ClassLoader externalClassLoader)
BaseHibernateValidatorConfiguration
META-INF/validation.xml
as well as XML constraint mappings)ValidationMessages
resource bundleexternalClassLoader
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
externalClassLoader
- The class loader for loading user-provided resources.this
following the chaining method patternpublic final ValidatorFactory buildValidatorFactory()
buildValidatorFactory
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final boolean isIgnoreXmlConfiguration()
isIgnoreXmlConfiguration
in interface ConfigurationState
public final MessageInterpolator getMessageInterpolator()
getMessageInterpolator
in interface ConfigurationState
public final Set<InputStream> getMappingStreams()
getMappingStreams
in interface ConfigurationState
public final boolean getFailFast()
public final ConstraintValidatorFactory getConstraintValidatorFactory()
getConstraintValidatorFactory
in interface ConfigurationState
public final TraversableResolver getTraversableResolver()
getTraversableResolver
in interface ConfigurationState
public BootstrapConfiguration getBootstrapConfiguration()
getBootstrapConfiguration
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public ParameterNameProvider getParameterNameProvider()
getParameterNameProvider
in interface ConfigurationState
public ClockProvider getClockProvider()
getClockProvider
in interface ConfigurationState
public PropertyNodeNameProvider getPropertyNodeNameProvider()
public LocaleResolver getLocaleResolver()
public ScriptEvaluatorFactory getScriptEvaluatorFactory()
public Duration getTemporalValidationTolerance()
public Object getConstraintValidatorPayload()
public GetterPropertySelectionStrategy getGetterPropertySelectionStrategy()
public Set<ValueExtractor<?>> getValueExtractors()
getValueExtractors
in interface ConfigurationState
public final Map<String,String> getProperties()
getProperties
in interface ConfigurationState
public ClassLoader getExternalClassLoader()
public final MessageInterpolator getDefaultMessageInterpolator()
getDefaultMessageInterpolator
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final TraversableResolver getDefaultTraversableResolver()
getDefaultTraversableResolver
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final ConstraintValidatorFactory getDefaultConstraintValidatorFactory()
getDefaultConstraintValidatorFactory
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public final ResourceBundleLocator getDefaultResourceBundleLocator()
BaseHibernateValidatorConfiguration
Returns the ResourceBundleLocator
used by the
default message
interpolator
to 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));
getDefaultResourceBundleLocator
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
ResourceBundleLocator
. Never null.public ParameterNameProvider getDefaultParameterNameProvider()
getDefaultParameterNameProvider
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public ClockProvider getDefaultClockProvider()
getDefaultClockProvider
in interface Configuration<T extends BaseHibernateValidatorConfiguration<T>>
public Set<ValueExtractor<?>> getDefaultValueExtractors()
BaseHibernateValidatorConfiguration
ValueExtractor
implementations as per the
specification.getDefaultValueExtractors
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
ValueExtractor
implementations compliant
with the specificationpublic T beanMetaDataClassNormalizer(BeanMetaDataClassNormalizer beanMetaDataClassNormalizer)
beanMetaDataClassNormalizer
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
public BeanMetaDataClassNormalizer getBeanMetaDataClassNormalizer()
public T constraintExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel)
BaseHibernateValidatorConfiguration
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.
constraintExpressionLanguageFeatureLevel
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
expressionLanguageFeatureLevel
- the ExpressionLanguageFeatureLevel
to be usedthis
following the chaining method patternpublic ExpressionLanguageFeatureLevel getConstraintExpressionLanguageFeatureLevel()
public T customViolationExpressionLanguageFeatureLevel(ExpressionLanguageFeatureLevel expressionLanguageFeatureLevel)
BaseHibernateValidatorConfiguration
This is the feature level used for messages of custom violations created by the ConstraintValidatorContext
.
customViolationExpressionLanguageFeatureLevel
in interface BaseHibernateValidatorConfiguration<T extends BaseHibernateValidatorConfiguration<T>>
expressionLanguageFeatureLevel
- the ExpressionLanguageFeatureLevel
to be usedthis
following the chaining method patternpublic ExpressionLanguageFeatureLevel getCustomViolationExpressionLanguageFeatureLevel()
public final Set<DefaultConstraintMapping> getProgrammaticMappings()
protected abstract boolean preloadResourceBundles()
protected T thisAsT()
Copyright © 2007-2021 Red Hat, Inc. All Rights Reserved