Modifier | Constructor and Description |
---|---|
protected |
ContextBuilder()
Constructs default
ContextBuilder . |
protected |
ContextBuilder(ValidationContext<?> parent)
Constructs a new
ContextBuilder for cascade validation. |
Modifier and Type | Method and Description |
---|---|
protected Validator.Context |
build()
Returns a new context with predefined custom parameters.
|
String |
buildMessage(Validation<?> component)
Builds localized error message for the specified validation
component using predefined custom parameters.
|
<V> V |
decodeValue(Converter<V> converter,
String value)
Converts string representation of value into object using the
specified converter and predefined custom parameters.
|
<V> V |
decodeValue(String property,
String value)
Converts string representation of property value into object using
predefined custom parameters.
|
<V> V[] |
decodeValues(Converter<V> converter,
String... values)
Converts array of string representations of values into array of
objects using the specified converter and predefined custom
parameters.
|
<V> V[] |
decodeValues(String property,
String... values)
Converts array of string representations of property values into
array of objects using predefined custom parameters.
|
<V> String |
encodeValue(Converter<V> converter,
V value)
Converts value into string representation using the specified
converter and predefined custom parameters.
|
<V> String |
encodeValue(String property,
V value)
Converts property value into string representation using predefined
custom parameters.
|
<V> String[] |
encodeValues(Converter<V> converter,
V... values)
Converts array of values into array of their string representations
using the specified converter and predefined custom parameters.
|
<V> String[] |
encodeValues(String property,
V... values)
Converts array of property values into array of their string
representations using predefined custom parameters.
|
String |
getEncodedValue(T entity,
String property)
Returns string representation of property value for the specified
entity using predefined custom parameters.
|
Map<String,String> |
getEncodedValues(T entity)
Returns string representations of property values for the specified
entity using predefined custom parameters.
|
Map<String,?> |
getValues(T entity)
Returns property values for the specified entity using predefined
custom parameters.
|
void |
setEncodedValue(T entity,
String property,
String value)
Assigns property value for the specified entity using predefined
custom parameters.
|
void |
setEncodedValues(T entity,
Map<String,String> values)
Assigns property values for the specified entity using predefined
custom parameters.
|
Validator.ContextBuilder |
setFailFast(boolean fail)
Sets flag that determines if validation should fail on the first
violation.
|
Validator.ContextBuilder |
setLocalizedConvert(boolean localized)
Sets flag that determines if converters should take locale into
account.
|
Validator.ContextBuilder |
setMessageLocale(Locale locale)
Sets locale to be used for error messages and formatting numbers,
dates, etc.
|
Validator.ContextBuilder |
setPropertyFilter(PropertyFilter filter)
Sets filter to be used for property filtering.
|
Validator.ContextBuilder |
setValidatingGroups(String... groups)
Sets array of constraint groups to be validated.
|
void |
setValues(T entity,
Map<String,?> values)
Assigns property values for the specified entity using predefined
custom parameters.
|
T |
validateEntity(T entity)
Validates the specified entity and returns possibly modified entity
using predefined custom parameters.
|
<V> V |
validateProperty(T entity,
String property)
Validates property value for the specified entity using predefined
custom parameters and assigns modified value to that property.
|
<V> V |
validateValue(String property,
Object value)
Validates the specified property value using predefined custom
parameters and returns possibly modified value.
|
protected ContextBuilder()
ContextBuilder
.protected ContextBuilder(ValidationContext<?> parent)
ContextBuilder
for cascade validation.parent
- Parent context.IllegalStateException
- if the specified context state is
invalid for cascade validation.protected Validator.Context build()
public final Validator.ContextBuilder setMessageLocale(Locale locale)
locale
- Locale to be used for error messages and formatting
numbers, dates, etc.public final Validator.ContextBuilder setPropertyFilter(PropertyFilter filter)
filter
- Filter to be used for property filtering.public final Validator.ContextBuilder setValidatingGroups(String... groups)
groups
- Array of constraint groups to be validated.public final Validator.ContextBuilder setLocalizedConvert(boolean localized)
localized
- Determines if converters should take locale into
account.public final Validator.ContextBuilder setFailFast(boolean fail)
fail
- Determines if validation should fail on the first
violation.public final Map<String,?> getValues(T entity)
entity
- Entity whose property values should be returned.IllegalArgumentException
- if the specified entity is
null
.public final void setValues(T entity, Map<String,?> values)
entity
- Entity whose property values should be assigned.values
- New property values.IllegalArgumentException
- if the specified entity is
null
.public final String getEncodedValue(T entity, String property)
entity
- Entity whose string representation of property value
should be returned.property
- Property name.IllegalArgumentException
- if the specified entity is
null
or the specified property not exists.UnsupportedOperationException
- if the specified property is
not readable.public final void setEncodedValue(T entity, String property, String value)
entity
- Entity whose property value should be assigned.property
- Property name.value
- String representation of property value.IllegalArgumentException
- if the specified entity is
null
or the specified property not exists.UnsupportedOperationException
- if the specified property is
not writeable.MalformedValueException
- if conversion fails.public final Map<String,String> getEncodedValues(T entity)
entity
- Entity whose string representations of property values
should be returned.IllegalArgumentException
- if the specified entity is
null
.public final void setEncodedValues(T entity, Map<String,String> values)
entity
- Entity whose property values should be assigned.values
- String representations of property values.IllegalArgumentException
- if the specified entity is
null
.ValidationException
- if conversion fails.public final <V> String encodeValue(String property, V value)
V
- The property value type.property
- Property name.value
- Property value to be encoded.IllegalArgumentException
- if the specified property not exists.public final <V> V decodeValue(String property, String value)
V
- The property value type.property
- Property name.value
- String representation of property value.IllegalArgumentException
- if the specified property not exists.MalformedValueException
- if conversion fails.@SafeVarargs public final <V> String[] encodeValues(String property, V... values)
V
- The property values type.property
- Property name.values
- Array of property values to be encoded.IllegalArgumentException
- if the specified property not exists.public final <V> V[] decodeValues(String property, String... values)
V
- The property values type.property
- Property name.values
- Array of string representations of property values.IllegalArgumentException
- if the specified property not exists.MalformedValueException
- if conversion fails.public final <V> String encodeValue(Converter<V> converter, V value)
V
- The value type.converter
- Converter to be used for value conversion.value
- Value to be encoded.public final <V> V decodeValue(Converter<V> converter, String value)
V
- The value type.converter
- Converter to be used for value conversion.value
- String representation of value.MalformedValueException
- if conversion fails.@SafeVarargs public final <V> String[] encodeValues(Converter<V> converter, V... values)
V
- The values type.converter
- Converter to be used for values conversion.values
- Array of values to be encoded.public final <V> V[] decodeValues(Converter<V> converter, String... values)
V
- The values type.converter
- Converter to be used for values conversion.values
- Array of string representations of values.MalformedValueException
- if conversion fails.public final T validateEntity(T entity)
entity
- Entity to be validated.IllegalArgumentException
- if the specified entity is
null
.ValidationException
- if validation fails.public final <V> V validateProperty(T entity, String property)
V
- The property value type.entity
- Entity whose property value should be validated.property
- Property name.IllegalArgumentException
- if the specified entity is
null
or the specified property not exists.ConstraintViolationException
- if validation fails.public final <V> V validateValue(String property, Object value)
V
- The property value type.property
- Property name.value
- Property value to be validated.IllegalArgumentException
- if the specified property not exists.ConstraintViolationException
- if validation fails.public final String buildMessage(Validation<?> component)
component
- Validation component.Copyright © 2011–2020 FoxLabs. All rights reserved.