public static class Validators.CollectionValidator<V,C extends java.util.Collection<? extends V>> extends Validators.RequiredValidator<C> implements ParentValidator<C>
CLASS_VERSION
Constructor and Description |
---|
CollectionValidator(boolean pRequired)
Create a new instance.
|
CollectionValidator(boolean pRequired,
Validator<? extends V> pValueValidator) |
CollectionValidator(java.lang.String pErrorCode,
boolean pRequired)
Create a new instance.
|
CollectionValidator(java.lang.String pErrorCode,
boolean pRequired,
java.lang.Class<? extends C> pRequiredClass)
Create a new instance.
|
CollectionValidator(java.lang.String pErrorCode,
boolean pRequired,
Validator<? extends V> pValueValidator)
Create a new instance.
|
Modifier and Type | Method and Description |
---|---|
protected C |
checkUniquePropertyValues(java.lang.String pPropertyName,
C pCollection,
ValidatorContext<?> pContext)
Check to make sure that any uniquePropertyNames have unique values
for each of the elements of pCollection.
|
protected C |
filterCollection(C pCollection,
ValidatorContext<?> pContext)
Filter pCollection, potentially returning a trimmed down copy of the
collection.
|
java.util.Map<java.lang.Object,Validator<?>> |
getChildValidatorMap()
Return a map form of the child validators, used for generating
a human readable representation of the parent-child relationship.
|
java.util.Collection<? extends Validator<?>> |
getChildValidators()
Get any child validators.
|
java.lang.Object |
getDefaultKeyForChildValidatorMap()
Return the default key for the childValidatorMap, if any.
|
java.lang.String[] |
getUniquePropertyNames()
Property names that must be unique among the child products.
|
Validator<? extends V> |
getValueValidator()
Return the value validator that validates individual members of our
collection.
|
protected java.util.List<java.lang.Object> |
listFromArray(java.lang.Object pArray)
Create an array list from an array.
|
void |
setChildValidatorMap(java.util.Map<?,Validator<?>> pChildMap)
Set the child validator map.
|
C |
validateValue(java.lang.String pPropertyName,
java.lang.Object pPropertyValue,
ValidatorContext<?> pContext)
Validate (and possibly convert) the specified property value.
|
getClassRequired, getRequiredOption, getRequiredPredicate, isRequired, keyMustBePresent, setClassRequired, setRequired, setRequiredOption, setRequiredPredicate
assertAlphanumeric, assertBoolean, assertDateTime, assertDouble, assertInstanceOf, assertInteger, assertLong, assertNotBlankString, assertNotEmpty, assertNotEmpty, assertNotNull, assertNotNull, assertString, assertString, assertString, createInstance, getBeanPropertyValueForValidation, getErrorCode, getNameForClass, getPropertyNames, getPropertyValue, getPropertyValue, hasProperty, isDigits, isRequired, setErrorCode, setPropertyValue, validateBeanProperty
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
validateBeanProperty
public CollectionValidator(java.lang.String pErrorCode, boolean pRequired)
pErrorCode
- the error code to use.pRequired
- whether a non-null value is required.public CollectionValidator(boolean pRequired)
pRequired
- whether a non-null value is required.public CollectionValidator(boolean pRequired, Validator<? extends V> pValueValidator)
public CollectionValidator(java.lang.String pErrorCode, boolean pRequired, Validator<? extends V> pValueValidator)
pErrorCode
- the error code to use.pRequired
- whether a non-null value is required.pValueValidator
- the validator to use for each value.public CollectionValidator(java.lang.String pErrorCode, boolean pRequired, java.lang.Class<? extends C> pRequiredClass)
pErrorCode
- the error code to use.pRequired
- whether a non-null value is required.pRequiredClass
- the required class for the collection.public Validator<? extends V> getValueValidator()
protected java.util.List<java.lang.Object> listFromArray(java.lang.Object pArray)
pArray
- thepublic C validateValue(java.lang.String pPropertyName, java.lang.Object pPropertyValue, ValidatorContext<?> pContext)
Validator
validateValue
in interface Validator<C extends java.util.Collection<? extends V>>
validateValue
in class Validators.RequiredValidator<C extends java.util.Collection<? extends V>>
pPropertyName
- the name of the property being validated. This
is typically used as a key for fetching the value from pProperties.pPropertyValue
- the fetched property valuepContext
- the current validation context.protected C filterCollection(C pCollection, ValidatorContext<?> pContext)
pCollection
- the collection to be filtered or returned.public java.util.Collection<? extends Validator<?>> getChildValidators()
Parentable
getChildValidators
in interface Parentable
public java.util.Map<java.lang.Object,Validator<?>> getChildValidatorMap()
Parentable
getChildValidatorMap
in interface Parentable
public void setChildValidatorMap(java.util.Map<?,Validator<?>> pChildMap)
Parentable
setChildValidatorMap
in interface Parentable
pChildMap
- the child validator map.public java.lang.Object getDefaultKeyForChildValidatorMap()
Parentable
getDefaultKeyForChildValidatorMap
in interface Parentable
public java.lang.String[] getUniquePropertyNames()
protected C checkUniquePropertyValues(java.lang.String pPropertyName, C pCollection, ValidatorContext<?> pContext)
pPropertyName
- the name of the collection property being validatedpCollection
- the actual collection being validatedpContext
- the list of errors.