org.jminor.common.model.valuemap
Class DefaultValueMapValidator<K,V>

java.lang.Object
  extended by 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.


Field Summary
 
Fields inherited from interface org.jminor.common.model.valuemap.ValueMapValidator
INSERT, UNKNOWN, UPDATE
 
Constructor Summary
DefaultValueMapValidator()
           
 
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
 

Constructor Detail

DefaultValueMapValidator

public DefaultValueMapValidator()
Method Detail

isNullable

public boolean isNullable(ValueMap<K,V> valueMap,
                          K key)

Specified by:
isNullable in interface ValueMapValidator<K,V>
Parameters:
valueMap - the value map
key - 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 map
action - 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 map
action - 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 validate
key - the key the value is associated with
action - 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