public class ValidatorFactory extends Object
Validator
instances.
The main purpose of this factory is maintaining validators configuration. You can configure factory once and then create validators with different metadata.
Validator
Modifier and Type | Field and Description |
---|---|
protected String |
datePattern
Default pattern for dates.
|
protected int |
dateStyle
Default date style.
|
protected String |
decimalPattern
Default pattern for decimal numbers.
|
protected String |
integerPattern
Default pattern for integer numbers.
|
protected MessageBuilder |
messageBuilder
Message builder to be used for building error messages.
|
protected MessageResolver |
messageResolver
Message resolver to be used for resolving localized messages.
|
protected int |
timeStyle
Default time style.
|
Constructor and Description |
---|
ValidatorFactory()
Constructs default
ValidatorFactory . |
ValidatorFactory(String bundleName)
Constructs a new
ValidatorFactory with the specified
message bundle name. |
Modifier and Type | Method and Description |
---|---|
static ValidatorFactory |
getDefault()
Returns immutable validator factory configured by default.
|
<T> Validator<T> |
newValidator(Class<T> type)
Creates a new validator for the specified bean type using factory
configuration.
|
<T> Validator<T> |
newValidator(Class<T> type,
Validator<?> config)
Creates a new validator for the specified bean type using configuration
from another validator.
|
<T> Validator<T> |
newValidator(EntityMetaData<T> metadata)
Creates a new validator for the specified entity metadata using factory
configuration.
|
<T> Validator<T> |
newValidator(EntityMetaData<T> metadata,
Validator<?> config)
Creates a new validator for the specified entity metadata using
configuration from another validator.
|
ValidatorFactory |
setDateFormat(int dateStyle,
int timeStyle)
Sets default format of dates according to the specified date and time
styles.
|
ValidatorFactory |
setDateFormat(String pattern)
Sets default format of dates according to the specified pattern.
|
ValidatorFactory |
setDecimalFormat(String pattern)
Sets default format of decimal numbers according to the specified
pattern.
|
ValidatorFactory |
setIntegerFormat(String pattern)
Sets default format of integer numbers according to the specified
pattern.
|
ValidatorFactory |
setMessageBuilder(MessageBuilder builder)
Sets message builder to be used for building error messages.
|
ValidatorFactory |
setMessageResolver(MessageResolver resolver)
Sets message resolver to be used for resolving localized messages.
|
protected String integerPattern
protected String decimalPattern
protected String datePattern
protected int dateStyle
protected int timeStyle
protected MessageResolver messageResolver
protected MessageBuilder messageBuilder
public ValidatorFactory()
ValidatorFactory
.public ValidatorFactory(String bundleName)
ValidatorFactory
with the specified
message bundle name.bundleName
- Message bundle name.public ValidatorFactory setIntegerFormat(String pattern)
pattern
- Default pattern for integer numbers.public ValidatorFactory setDecimalFormat(String pattern)
pattern
- Default pattern for decimal numbers.public ValidatorFactory setDateFormat(String pattern)
pattern
- Default pattern for dates.public ValidatorFactory setDateFormat(int dateStyle, int timeStyle)
dateStyle
- Default date style.timeStyle
- Default time style.public ValidatorFactory setMessageResolver(MessageResolver resolver)
resolver
- Message resolver to be used for resolving localized
messages.public ValidatorFactory setMessageBuilder(MessageBuilder builder)
builder
- Message builder to be used for building error messages.public <T> Validator<T> newValidator(Class<T> type)
T
- The bean type.type
- Bean type for which validator should be created.public <T> Validator<T> newValidator(Class<T> type, Validator<?> config)
T
- The bean type.type
- Bean type for which validator should be created.config
- Validator whose configuration should be taken.public <T> Validator<T> newValidator(EntityMetaData<T> metadata)
T
- The entity type.metadata
- Entity metadata for which validator should be created.public <T> Validator<T> newValidator(EntityMetaData<T> metadata, Validator<?> config)
T
- The entity type.metadata
- Entity metadata.config
- Validator whose configuration should be taken.public static ValidatorFactory getDefault()
Copyright © 2011–2020 FoxLabs. All rights reserved.