Class RequiredValidation
- java.lang.Object
-
- org.cyclos.impl.utils.validation.validations.BasePropertyValidation
-
- org.cyclos.impl.utils.validation.validations.RequiredValidation
-
- All Implemented Interfaces:
GeneralValidation,PropertyValidation
public class RequiredValidation extends BasePropertyValidation implements GeneralValidation
A validation (both property and general) that ensures that a given property is not empty. Handles objects in general (rejecting null values), entity models (rejecting with null ids), strings (rejecting empty strings), collections, maps and arrays (rejecting empty collections)
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.utils.validation.validations.BasePropertyValidation
error
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanhandleEmpty()May be overridden in order to indicate that empty values should be validatedstatic booleanisValid(Object value)Returns whether the given object is considered valid ("not empty", depending on the specific type semantics)protected booleanisValid(Object object, Object property, Object value)Should be implemented to return whether the value is valid.ValidationErrorvalidate(Object object)Validates the object-
Methods inherited from class org.cyclos.impl.utils.validation.validations.BasePropertyValidation
getConversionHandler, getEntityManagerHandler, validate
-
-
-
-
Method Detail
-
isValid
public static boolean isValid(Object value)
Returns whether the given object is considered valid ("not empty", depending on the specific type semantics)
-
validate
public ValidationError validate(Object object)
Description copied from interface:GeneralValidationValidates the object- Specified by:
validatein interfaceGeneralValidation
-
handleEmpty
protected boolean handleEmpty()
Description copied from class:BasePropertyValidationMay be overridden in order to indicate that empty values should be validated- Overrides:
handleEmptyin classBasePropertyValidation
-
isValid
protected boolean isValid(Object object, Object property, Object value)
Description copied from class:BasePropertyValidationShould be implemented to return whether the value is valid. If the value is valid, theBasePropertyValidation.validate(Object, Object, Object)method will return null. Otherwise, will return theValidationErrorreceived on the constructor (or a general validation error if none was passed)- Specified by:
isValidin classBasePropertyValidation
-
-