public static class Domain.Validator extends DefaultValueMap.DefaultValidator<Property,Entity> implements Entity.Validator
Entity.Validator
implementation providing null validation for properties marked as not null,
range validation for numerical properties with max and/or min values specified and string length validation
based on the specified max length.
This Validator can be extended to provide further validation.Property.Builder#setNullable(boolean)
,
Property.Builder#setMin(double)
,
Property.Builder#setMax(double)
,
Property.Builder#setMaxLength(int)
,
Serialized FormConstructor and Description |
---|
Validator()
Instantiates a new
Entity.Validator |
Validator(boolean performNullValidation)
Instantiates a new
Entity.Validator |
Modifier and Type | Method and Description |
---|---|
boolean |
isNullable(Entity entity,
Property property)
Returns true if the given property accepts a null value for the given entity,
by default this method simply returns
property.isNullable() |
void |
performLengthValidation(Entity entity,
Property property)
Performs a length validation on the given string based property
|
void |
performNullValidation(Entity entity,
Property property)
Performs a null validation on the given property
|
void |
performRangeValidation(Entity entity,
Property property)
Performs a range validation on the given number based property
|
void |
validate(java.util.Collection<Entity> entities)
Validates all writable properties in the given entities
|
void |
validate(Entity entity)
Validates all writable properties in the given entity
|
void |
validate(Entity entity,
Property property)
Checks if the value associated with the give key is valid, throws a ValidationException if not
|
addRevalidationListener, isValid, removeRevalidationListener, revalidate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addRevalidationListener, isValid, removeRevalidationListener, revalidate
public Validator()
Entity.Validator
public Validator(boolean performNullValidation)
Entity.Validator
performNullValidation
- if true then automatic null validation is performedpublic boolean isNullable(Entity entity, Property property)
property.isNullable()
isNullable
in interface ValueMap.Validator<Property,Entity>
isNullable
in class DefaultValueMap.DefaultValidator<Property,Entity>
entity
- the entity being validatedproperty
- the propertypublic final void validate(java.util.Collection<Entity> entities) throws ValidationException
validate
in interface Entity.Validator
entities
- the entities to validateValidationException
- in case validation failspublic void validate(Entity entity) throws ValidationException
validate
in interface ValueMap.Validator<Property,Entity>
validate
in class DefaultValueMap.DefaultValidator<Property,Entity>
entity
- the entity to validateValidationException
- in case validation failspublic void validate(Entity entity, Property property) throws ValidationException
validate
in interface ValueMap.Validator<Property,Entity>
validate
in class DefaultValueMap.DefaultValidator<Property,Entity>
entity
- the value map to validateproperty
- the key the value is associated withValidationException
- if the given value is not valid for the given keypublic final void performRangeValidation(Entity entity, Property property) throws RangeValidationException
performRangeValidation
in interface Entity.Validator
entity
- the entityproperty
- the propertyRangeValidationException
- in case the value of the given property is outside the legal rangeProperty.Builder#setMax(double)
,
Property.Builder#setMin(double)
public final void performNullValidation(Entity entity, Property property) throws NullValidationException
performNullValidation
in interface Entity.Validator
entity
- the entityproperty
- the propertyNullValidationException
- in case the property value is null and the property is not nullableProperty.Builder#setNullable(boolean)
,
Property.isNullable()
public void performLengthValidation(Entity entity, Property property) throws LengthValidationException
performLengthValidation
in interface Entity.Validator
entity
- the entityproperty
- the propertyLengthValidationException
- in case the length of the value of the given propertyProperty.Builder#setMaxLength(int)