Class BaseEntityValidation<E extends SimpleEntity>
- java.lang.Object
-
- org.cyclos.impl.utils.validation.validations.BaseEntityValidation<E>
-
- All Implemented Interfaces:
EntityValidation<E>
public abstract class BaseEntityValidation<E extends SimpleEntity> extends Object implements EntityValidation<E>
Base implementation forEntityValidationwhich declares the easierisValid(Object, Object, SimpleEntity)method which returns a boolean, indicating whether the property is valid
-
-
Field Summary
Fields Modifier and Type Field Description protected ValidationErrorerror
-
Constructor Summary
Constructors Constructor Description BaseEntityValidation()Without specifying aValidationError,ValidationErrors.invalid()is assumedBaseEntityValidation(ValidationError error)Uses the givenValidationErrorBaseEntityValidation(MessageKey key, Object... args)Uses the givenMessageKey
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected EntityManagerHandlergetEntityManagerHandler()Returns anEntityManagerHandlerwhich can be used by validations which need database accessprotected abstract booleanisValid(Object object, Object property, E entity)Should be implemented to return whether the value is valid.ValidationErrorvalidate(Object object, Object property, E entity)Returns aValidationErrorif the property is invalid, or null if the property is valid
-
-
-
Field Detail
-
error
protected final ValidationError error
-
-
Constructor Detail
-
BaseEntityValidation
public BaseEntityValidation()
Without specifying aValidationError,ValidationErrors.invalid()is assumed
-
BaseEntityValidation
public BaseEntityValidation(MessageKey key, Object... args)
Uses the givenMessageKey
-
BaseEntityValidation
public BaseEntityValidation(ValidationError error)
Uses the givenValidationError
-
-
Method Detail
-
validate
public final ValidationError validate(Object object, Object property, E entity)
Description copied from interface:EntityValidationReturns aValidationErrorif the property is invalid, or null if the property is valid- Specified by:
validatein interfaceEntityValidation<E extends SimpleEntity>
-
getEntityManagerHandler
protected EntityManagerHandler getEntityManagerHandler()
Returns anEntityManagerHandlerwhich can be used by validations which need database access
-
isValid
protected abstract boolean isValid(Object object, Object property, E entity)
Should be implemented to return whether the value is valid. If the value is valid, thevalidate(Object, Object, SimpleEntity)method will return null. Otherwise, will return theValidationErrorreceived on the constructor (or a general validation error if none was passed)
-
-