org.jminor.common.model.valuemap
Class DefaultValueMapValidator<K,V>
java.lang.Object
org.jminor.common.model.valuemap.DefaultValueMapValidator<K,V>
- All Implemented Interfaces:
- ValueMapValidator<K,V>
- Direct Known Subclasses:
- Entities.Validator
public class DefaultValueMapValidator<K,V>
- extends Object
- implements ValueMapValidator<K,V>
A default value map validator implementation, which performs basic null validation.
Method Summary |
boolean |
isNullable(ValueMap<K,V> valueMap,
K key)
|
boolean |
isValid(ValueMap<K,V> valueMap,
int action)
|
void |
validate(ValueMap<K,V> valueMap,
int action)
Checks if the values in the given value map are valid |
void |
validate(ValueMap<K,V> valueMap,
K key,
int action)
Checks if the value associated with the give key is valid, throws a ValidationException if not |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DefaultValueMapValidator
public DefaultValueMapValidator()
isNullable
public boolean isNullable(ValueMap<K,V> valueMap,
K key)
-
- Specified by:
isNullable
in interface ValueMapValidator<K,V>
- Parameters:
valueMap
- the value mapkey
- the key
- Returns:
- true if this value is allowed to be null in the given value map
isValid
public boolean isValid(ValueMap<K,V> valueMap,
int action)
-
- Specified by:
isValid
in interface ValueMapValidator<K,V>
- Parameters:
valueMap
- the value mapaction
- the action requiring validation
- Returns:
- true if the given value map contains only valid values
validate
public void validate(ValueMap<K,V> valueMap,
int action)
throws ValidationException
- Checks if the values in the given value map are valid
- Specified by:
validate
in interface ValueMapValidator<K,V>
- Parameters:
valueMap
- the value mapaction
- the action requiring validation
- Throws:
ValidationException
- in case of an invalid value
validate
public void validate(ValueMap<K,V> valueMap,
K key,
int action)
throws ValidationException
- Checks if the value associated with the give key is valid, throws a ValidationException if not
- Specified by:
validate
in interface ValueMapValidator<K,V>
- Parameters:
valueMap
- the value map to validatekey
- the key the value is associated withaction
- describes the action requiring validation,
ValueChangeMapEditModel.INSERT, ValueChangeMapEditModel.UPDATE or ValueChangeMapEditModel.UNKNOWN
- Throws:
ValidationException
- if the given value is not valid for the given key