org.jminor.framework.domain
Class Entities.Validator

java.lang.Object
  extended by org.jminor.common.model.valuemap.DefaultValueMapValidator<String,Object>
      extended by org.jminor.framework.domain.Entities.Validator
All Implemented Interfaces:
ValueMapValidator<String,Object>, Entity.Validator
Enclosing class:
Entities

public static class Entities.Validator
extends DefaultValueMapValidator<String,Object>
implements Entity.Validator

A default extensible Entity.Validator implementation.


Field Summary
 
Fields inherited from interface org.jminor.common.model.valuemap.ValueMapValidator
INSERT, UNKNOWN, UPDATE
 
Constructor Summary
Entities.Validator(String entityID)
          Instantiates a new EntityValidator
 
Method Summary
 String getEntityID()
          
 boolean isNullable(ValueMap<String,Object> valueMap, String key)
          Returns true if the given property accepts a null value for the given entity, by default this method simply returns property.isNullable()
 void performNullValidation(Entity entity, Property property, int action)
          Performs a null validation on the given property
 void performRangeValidation(Entity entity, Property property)
          Performs a range validation on the given property
 void validate(Collection<Entity> entities, int action)
          Validates the given Entity objects.
 void validate(Entity entity, int action)
          Validates the values in the given entity
 void validate(Entity entity, String propertyID, int action)
          Validates the given property in the given entity
 void validate(ValueMap<String,Object> valueMap, int action)
          Checks if the values in the given value map are valid
 void validate(ValueMap<String,Object> valueMap, String key, int action)
          Checks if the value associated with the give key is valid, throws a ValidationException if not
 
Methods inherited from class org.jminor.common.model.valuemap.DefaultValueMapValidator
isValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jminor.common.model.valuemap.ValueMapValidator
isValid
 

Constructor Detail

Entities.Validator

public Entities.Validator(String entityID)
Instantiates a new EntityValidator

Parameters:
entityID - the ID of the entities to validate
Method Detail

getEntityID

public final String getEntityID()

Specified by:
getEntityID in interface Entity.Validator
Returns:
the ID of the entity this validator validates

isNullable

public boolean isNullable(ValueMap<String,Object> valueMap,
                          String key)
Returns true if the given property accepts a null value for the given entity, by default this method simply returns property.isNullable()

Specified by:
isNullable in interface ValueMapValidator<String,Object>
Overrides:
isNullable in class DefaultValueMapValidator<String,Object>
Parameters:
valueMap - the entity being validated
key - the property ID
Returns:
true if the property accepts a null value

validate

public void validate(Entity entity,
                     int action)
              throws ValidationException
Validates the values in the given entity

Specified by:
validate in interface Entity.Validator
Parameters:
entity - the entity to validate
action - the action requiring validation
Throws:
ValidationException - in case the validation fails
See Also:
Property.setNullable(boolean), Configuration.PERFORM_NULL_VALIDATION

validate

public final void validate(Collection<Entity> entities,
                           int action)
                    throws ValidationException
Validates the given Entity objects.

Specified by:
validate in interface Entity.Validator
Parameters:
entities - the entities to validate
action - describes the action requiring validation, EntityEditor.INSERT, EntityEditor.UPDATE or EntityEditor.UNKNOWN
Throws:
ValidationException - in case the validation fails

validate

public final void validate(ValueMap<String,Object> valueMap,
                           int action)
                    throws ValidationException
Checks if the values in the given value map are valid

Specified by:
validate in interface ValueMapValidator<String,Object>
Overrides:
validate in class DefaultValueMapValidator<String,Object>
Parameters:
valueMap - the value map
action - the action requiring validation
Throws:
ValidationException - in case of an invalid value

validate

public final void validate(ValueMap<String,Object> valueMap,
                           String 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<String,Object>
Overrides:
validate in class DefaultValueMapValidator<String,Object>
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

validate

public void validate(Entity entity,
                     String propertyID,
                     int action)
              throws ValidationException
Validates the given property in the given entity

Specified by:
validate in interface Entity.Validator
Parameters:
entity - the entity to validate
propertyID - the ID of the property to validate
action - the action requiring validation
Throws:
ValidationException - in case the validation fails
See Also:
Property.setNullable(boolean), Configuration.PERFORM_NULL_VALIDATION

performRangeValidation

public final void performRangeValidation(Entity entity,
                                         Property property)
                                  throws RangeValidationException
Performs a range validation on the given property

Specified by:
performRangeValidation in interface Entity.Validator
Parameters:
entity - the entity
property - the property
Throws:
RangeValidationException - in case the value of the given property is outside the legal range
See Also:
Property.setMax(double), Property.setMin(double)

performNullValidation

public final void performNullValidation(Entity entity,
                                        Property property,
                                        int action)
                                 throws NullValidationException
Performs a null validation on the given property

Specified by:
performNullValidation in interface Entity.Validator
Parameters:
entity - the entity
property - the property
action - the action requiring validation
Throws:
NullValidationException - in case the proerty value is null and the property is not nullable
See Also:
Property.isNullable()