public class MapUpdatingValidator<V> extends Validators.MapValidator<V> implements UpdatingValidator<java.util.Map<java.lang.String,V>>, BeanValidator, atg.service.validator.RegistryAwareValidator<java.util.Map<java.lang.String,V>>
This class makes the following assumptions:
Created: August 14 2014
UpdatingValidator.NoOpValidator<T>, UpdatingValidator.NullObjectIfNulledUpdatingValidator, UpdatingValidator.PropertyUpdateActionBeanValidator.NoOpBeanValidator| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected static VariableArgumentApplicationLogging |
LOGGER |
NO_OPNO_OP_BEAN_VALIDATOR| Constructor and Description |
|---|
MapUpdatingValidator()
Create a new instance.
|
MapUpdatingValidator(boolean pRequired)
Create a new instance.
|
MapUpdatingValidator(boolean pRequired,
Validator<? extends V> pValueValidator)
Create a new instance.
|
MapUpdatingValidator(java.lang.String pErrorCode,
boolean pRequired)
Create a new instance.
|
MapUpdatingValidator(java.lang.String pErrorCode,
boolean pRequired,
Validator<? extends V> pValueValidator)
Create a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected MapUpdateHelper |
createDefaultMapUpdateHelper() |
protected boolean |
createEquivalentAlsoAdds(java.lang.Object pTargetMap,
ValidatorContext<?> pContext)
Return whether creation a matching target also adds to the collection.&=
This method is needed because we delay adding values to the map until after
the element is processed.
|
protected V |
createEquivalentForMap(java.lang.String pKey,
java.lang.Object pSourceValue,
java.lang.Object pMapDst,
ValidatorContext<?> pContext)
Get/create an equivalent object for the value map.
|
protected java.lang.Object |
createMapDestination(java.lang.String pPropertyName,
java.lang.Object pTarget,
ValidatorContext<?> pContext)
If the Map on the on the target bean is null, this method will be invoked.
|
atg.service.validator.BeanValidatorRegistry |
getBeanValidatorRegistry() |
atg.service.validator.BeanValidatorRegistry |
getRegistry()
Returns property registry.
|
java.lang.Class |
getTargetBeanValueCreateType()
Returns property targetBeanValueCreateType.
|
java.lang.Class |
getTargetMapCreateType()
Returns property targetMapCreateType.
|
MapUpdateHelper<?,V> |
getUpdateHelper()
Returns property updateHelper.
|
boolean |
isAutoCreateMapTargetGuess()
Returns property autoCreateMapTargetGuess.
|
protected void |
putNewTargetValue(java.lang.Object pTargetMap,
java.lang.String pKey,
java.lang.Object pTargetValue,
ValidatorContext<?> pContext)
Add a put a target value to the target map.
|
protected void |
removeKeyFromMap(java.lang.String pKey,
java.lang.Object pMapDst,
ValidatorContext<?> pContext)
Remove the key pKey from the map pMapDst.
|
void |
setAutoCreateMapTargetGuess(boolean pAutoCreateMapTargetGuess)
Sets property autoCreateMapTargetGuess.
|
void |
setBeanValidatorRegistry(atg.service.validator.BeanValidatorRegistry pRegistry) |
void |
setRegistry(atg.service.validator.BeanValidatorRegistry pRegistry)
Sets property registry.
|
void |
setTargetBeanValueCreateType(java.lang.Class pTargetBeanValueCreateType)
Sets property targetBeanValueCreateType.
|
void |
setTargetMapCreateType(java.lang.Class pTargetMapCreateType)
Sets property targetMapCreateType.
|
void |
setUpdateHelper(MapUpdateHelper<?,V> pUpdateHelper)
Sets property updateHelper.
|
protected boolean |
shouldSetCreatedMapAsProperty(java.lang.Object pTargetMap,
ValidatorContext<?> pContext)
Return whether to set the created map as a property of the parent.
|
void |
updateBean(java.lang.Object pSource,
java.lang.Object pTarget,
ValidatorContext<?> pContext)
Update the target bean with properties from pSource.
|
UpdatingValidator.PropertyUpdateAction |
updateBeanValue(java.lang.String pPropertyName,
java.lang.Object pSource,
java.lang.Object pTarget,
ValidatorContext<?> pContext)
Typically invoked by
ValidatorManager. |
void |
validateBean(java.lang.Object pBean,
ValidatorContext<?> pContext)
Validate the specified bean.
|
getChildValidatorMap, getChildValidators, getDefaultKeyForChildValidatorMap, setChildValidatorMap, setKeyValidator, setValueValidator, validateValuegetClassesRequired, getClassRequired, getRequiredOption, getRequiredPredicate, isRequired, isSourceOnly, keyMustBePresent, setClassesRequired, setClassRequired, setRequired, setRequiredOption, setRequiredPredicate, setSourceOnlyassertAlphanumeric, assertBoolean, assertDateTime, assertDouble, assertInstanceOf, assertInstanceOf, assertInteger, assertInteger, assertLong, assertNotBlankString, assertNotEmpty, assertNotEmpty, assertNotNull, assertNotNull, assertString, assertString, assertString, assertUnicodeAlphanumeric, createInstance, createInstance, getBeanPropertyValueForValidation, getCheckedBeanPropertyValueForValidation, getErrorCode, getNameForClass, getNameForClasses, getParentValidator, getPropertyNames, getPropertyValue, getPropertyValue, hasProperty, isDigits, isRequired, setErrorCode, setParentValidator, setPropertyValue, validateBeanPropertyclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitvalidateBeanProperty, validateValuegetErrorCode, setErrorCodepublic static java.lang.String CLASS_VERSION
protected static final VariableArgumentApplicationLogging LOGGER
public MapUpdatingValidator()
public MapUpdatingValidator(boolean pRequired)
pRequired - whether or not a non-null value is required.public MapUpdatingValidator(boolean pRequired,
Validator<? extends V> pValueValidator)
pRequired - whether or not a non-null value is required.pValueValidator - the validator to use to validate the values (rather than the keys)
of the map.public MapUpdatingValidator(java.lang.String pErrorCode,
boolean pRequired)
pErrorCode - the string error code to report on CCExceptions created by this
validator.pRequired - whether or not a non-null value is required.public MapUpdatingValidator(java.lang.String pErrorCode,
boolean pRequired,
Validator<? extends V> pValueValidator)
pErrorCode - the string error code to report on CCExceptions created by this
validator.pRequired - whether or not a non-null value is required.pValueValidator - the validator to use to validate the values (rather than the keys)
of the map.public void setAutoCreateMapTargetGuess(boolean pAutoCreateMapTargetGuess)
public boolean isAutoCreateMapTargetGuess()
public void setRegistry(atg.service.validator.BeanValidatorRegistry pRegistry)
public atg.service.validator.BeanValidatorRegistry getRegistry()
public void setBeanValidatorRegistry(atg.service.validator.BeanValidatorRegistry pRegistry)
setBeanValidatorRegistry in interface atg.service.validator.RegistryAwareValidator<java.util.Map<java.lang.String,V>>public atg.service.validator.BeanValidatorRegistry getBeanValidatorRegistry()
getBeanValidatorRegistry in interface atg.service.validator.RegistryAwareValidator<java.util.Map<java.lang.String,V>>public void setTargetMapCreateType(java.lang.Class pTargetMapCreateType)
public java.lang.Class getTargetMapCreateType()
public void setTargetBeanValueCreateType(java.lang.Class pTargetBeanValueCreateType)
public java.lang.Class getTargetBeanValueCreateType()
public void setUpdateHelper(MapUpdateHelper<?,V> pUpdateHelper)
public MapUpdateHelper<?,V> getUpdateHelper()
public UpdatingValidator.PropertyUpdateAction updateBeanValue(java.lang.String pPropertyName, java.lang.Object pSource, java.lang.Object pTarget, ValidatorContext<?> pContext)
UpdatingValidatorValidatorManager. Update
a bean value from a source value. Note that if a new target bean
is created, pContext.replaceParentDst() may need to be invoked.updateBeanValue in interface UpdatingValidator<java.util.Map<java.lang.String,V>>pSource - the value of pPropertyName property of the source
beanpTarget - the existing value of pPropertyName of the target
beanpContext - the current update context (with the
current source/target parent beans).public void validateBean(java.lang.Object pBean,
ValidatorContext<?> pContext)
BeanValidatorvalidateBean in interface BeanValidatorpBean - the bean to validatepContext - the validator context to which any validation
errors will be added.public void updateBean(java.lang.Object pSource,
java.lang.Object pTarget,
ValidatorContext<?> pContext)
BeanValidatorupdateBean in interface BeanValidatorpSource - the source beanpTarget - the target beanpContext - the validator context.protected java.lang.Object createMapDestination(java.lang.String pPropertyName,
java.lang.Object pTarget,
ValidatorContext<?> pContext)
pPropertyName - the property name being createdpTarget - the target bean.pContext - the update context.protected V createEquivalentForMap(java.lang.String pKey, java.lang.Object pSourceValue, java.lang.Object pMapDst, ValidatorContext<?> pContext)
pKey - the map key to create a value for.pSourceValue - the value for the key in the source map.pMapDst - the target map into which the returned object will be placed.pContext - the update context.protected void removeKeyFromMap(java.lang.String pKey,
java.lang.Object pMapDst,
ValidatorContext<?> pContext)
throws PropertyNotFoundException
pKey - the key to remove from the mappMapDst - the destination map from which to remove the keypContext - the current update context.PropertyNotFoundExceptionprotected boolean createEquivalentAlsoAdds(java.lang.Object pTargetMap,
ValidatorContext<?> pContext)
pTargetMap - the target map.pContext - the update context.protected boolean shouldSetCreatedMapAsProperty(java.lang.Object pTargetMap,
ValidatorContext<?> pContext)
pContext - the update context.protected void putNewTargetValue(java.lang.Object pTargetMap,
java.lang.String pKey,
java.lang.Object pTargetValue,
ValidatorContext<?> pContext)
throws PropertyNotFoundException
pTargetMap - the map to add the value to.pKey - the key to add to the target map.pTargetValue - the new value to add to the map.pContext - the update context.PropertyNotFoundExceptionprotected MapUpdateHelper createDefaultMapUpdateHelper()