Class ValidatorAdapter
java.lang.Object
org.springframework.boot.autoconfigure.validation.ValidatorAdapter
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.beans.factory.DisposableBean
,org.springframework.beans.factory.InitializingBean
,org.springframework.context.ApplicationContextAware
,org.springframework.validation.SmartValidator
,org.springframework.validation.Validator
public class ValidatorAdapter
extends Object
implements org.springframework.validation.SmartValidator, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
Validator
implementation that delegates calls to another Validator
.
This Validator
implements Spring's SmartValidator
interface but does
not implement the JSR-303 jakarta.validator.Validator
interface.- Since:
- 2.0.0
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
destroy()
static org.springframework.validation.Validator
get
(org.springframework.context.ApplicationContext applicationContext, org.springframework.validation.Validator validator) Return aValidator
that only implements theValidator
interface, wrapping it if necessary.final org.springframework.validation.Validator
void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) boolean
void
void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.validation.SmartValidator
validateValue
-
Method Details
-
getTarget
public final org.springframework.validation.Validator getTarget() -
supports
- Specified by:
supports
in interfaceorg.springframework.validation.Validator
-
validate
- Specified by:
validate
in interfaceorg.springframework.validation.Validator
-
validate
public void validate(Object target, org.springframework.validation.Errors errors, Object... validationHints) - Specified by:
validate
in interfaceorg.springframework.validation.SmartValidator
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.BeansException
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-
get
public static org.springframework.validation.Validator get(org.springframework.context.ApplicationContext applicationContext, org.springframework.validation.Validator validator) Return aValidator
that only implements theValidator
interface, wrapping it if necessary.If the specified
Validator
is notnull
, it is wrapped. If not, aValidator
is retrieved from the context and wrapped. Otherwise, a new default validator is created.- Parameters:
applicationContext
- the application contextvalidator
- an existing validator to use ornull
- Returns:
- the validator to use
-