public class CollectionUniqueKeyValidator extends NuitonFieldValidatorSupport
FieldExpressionValidator qui valide une clef
unique sur une collection.
Le FieldValidatorSupport.fieldName sert à récupérer la propriété de type de collection du
bean.| Modifier and Type | Field and Description |
|---|---|
protected String |
againstIndexExpression
Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser
le equals sur l'objet, on peut spécifier une expression pour exclure des
tests lors de la recherche de la violation de clef unique.
|
protected boolean |
againstMe
Une propriété optionnelle pour utiliser l'objet en cours de validation pour
valider que l'objet reflétée par cette propriété ne viole pas l'intégrité de la clef unique.
|
protected String |
againstProperty
Une propriété optionnelle pour valider que l'objet reflétée par cette
propriété ne viole pas l'intégrité de la clef unique.
|
protected String |
collectionFieldName
pour indiquer la propriété qui contient la liste à valider.
|
protected String[] |
keys
la liste des propriétés d'une entrée de la collection qui définit la
clef unique.
|
protected boolean |
nullValueSkipped
Pour ne pas traiter les valeurs nulles (si positionné à
true les
valeurs nulles ne sont pas considérée comme unique). |
skip| Constructor and Description |
|---|
CollectionUniqueKeyValidator() |
| Modifier and Type | Method and Description |
|---|---|
String |
getAgainstIndexExpression() |
boolean |
getAgainstMe() |
String |
getAgainstProperty() |
protected Collection<?> |
getCollection(Object object) |
String |
getCollectionFieldName() |
String[] |
getKeys() |
protected Integer |
getUniqueKeyHashCode(Object o)
Calcule pour une entrée donné, le hash de la clef unique
|
String |
getValidatorType() |
boolean |
isNullValueSkipped() |
void |
setAgainstIndexExpression(String againstIndexExpression) |
void |
setAgainstMe(boolean againstMe) |
void |
setAgainstProperty(String againstProperty) |
void |
setCollectionFieldName(String collectionFieldName) |
void |
setKeys(String[] keys) |
void |
setNullValueSkipped(boolean nullValueSkipped) |
void |
validateWhenNotSkip(Object object)
Method to be invoked when skip parameter was not evaludated to
true. |
evaluateSkipParameter, getFieldValue, setSkip, validategetCurrentValue, getFieldName, setFieldName, setValidatorTypeaddActionError, addFieldError, getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setTextProviderFactory, setValidatorContext, setValueStackprotected String collectionFieldName
FieldValidatorSupport.getFieldName() pour obtenir la collection.
Cela permet d'effectuer une validation si une collection mais portant
en fait sur un autre champsprotected String[] keys
protected String againstProperty
protected boolean againstMe
protected String againstIndexExpression
protected boolean nullValueSkipped
true les
valeurs nulles ne sont pas considérée comme unique).public String getCollectionFieldName()
public void setCollectionFieldName(String collectionFieldName)
public String[] getKeys()
public boolean getAgainstMe()
public void setKeys(String[] keys)
public String getAgainstProperty()
public void setAgainstProperty(String againstProperty)
public String getAgainstIndexExpression()
public void setAgainstIndexExpression(String againstIndexExpression)
public void setAgainstMe(boolean againstMe)
public boolean isNullValueSkipped()
public void setNullValueSkipped(boolean nullValueSkipped)
public void validateWhenNotSkip(Object object) throws com.opensymphony.xwork2.validator.ValidationException
NuitonFieldValidatorSupporttrue.validateWhenNotSkip in class NuitonFieldValidatorSupportobject - the object to be validated.com.opensymphony.xwork2.validator.ValidationException - is thrown if there is validation error(s).protected Integer getUniqueKeyHashCode(Object o) throws com.opensymphony.xwork2.validator.ValidationException
o - l'entree de la collection dont on va calculer le hash de
la clef uniquecom.opensymphony.xwork2.validator.ValidationException - if any pb to retreave properties valuesprotected Collection<?> getCollection(Object object) throws com.opensymphony.xwork2.validator.ValidationException
object - the incoming object containing the collection to testcom.opensymphony.xwork2.validator.ValidationException - if any pb to retreave the collectionpublic String getValidatorType()
getValidatorType in interface com.opensymphony.xwork2.validator.ValidatorgetValidatorType in class com.opensymphony.xwork2.validator.validators.FieldValidatorSupportCopyright © 2013–2017 CodeLutin. All rights reserved.