Class ValidationHelper
java.lang.Object
overit.geocallapp.utilities.core.bl.common.validation.ValidationHelper
Utility class that provides validation methods for common validation scenarios.
The class uses a singleton pattern per company, with instances cached in a static map.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ValidationHelperReturns the validation helper.voidvalidateDateInterval(String startDateName, String endDateName, Date startDate, Date endDate) Validates if the start date of an interval is before or equal to the end date.<O> voidvalidateEntityExistence(Class<? extends LoadEvent<O>> loadEventClass, Long id, PoolKit poolKit) Validates the existence of an entity.voidvalidateFieldLength(String fieldName, Object fieldValue, int fieldLength) Validates the length of a field.voidvalidateNotNullField(String fieldName, Object fieldValue, boolean isInsertOperation) Validates if a required field has a value.
-
Constructor Details
-
ValidationHelper
public ValidationHelper()
-
-
Method Details
-
getValidationHelper
Returns the validation helper.- Returns:
- the
ValidationHelper
-
validateNotNullField
public void validateNotNullField(String fieldName, Object fieldValue, boolean isInsertOperation) throws DAValidateException Validates if a required field has a value.- Parameters:
fieldName- the field namefieldValue- the field valueisInsertOperation- true if the validation is linked to an insertion operation, false otherwise- Throws:
DAValidateException- if the field value is null or empty (in the case of a string)
-
validateFieldLength
public void validateFieldLength(String fieldName, Object fieldValue, int fieldLength) throws DAValidateException Validates the length of a field.- Parameters:
fieldName- the field namefieldValue- the field valuefieldLength- the maximum field length- Throws:
DAValidateException- if the field value length is greater than maximum field length
-
validateDateInterval
public void validateDateInterval(String startDateName, String endDateName, Date startDate, Date endDate) throws DAValidateException Validates if the start date of an interval is before or equal to the end date.- Parameters:
startDateName- the start date nameendDateName- the end date namestartDate- the start dateendDate- the end date- Throws:
DAValidateException- if start date is after the end date
-
validateEntityExistence
public <O> void validateEntityExistence(Class<? extends LoadEvent<O>> loadEventClass, Long id, PoolKit poolKit) throws DAValidateException, DAException Validates the existence of an entity.- Type Parameters:
O- the type of the entity- Parameters:
loadEventClass- the class of load entityid- the identifier of the entitypoolKit- thePoolKitto use for launch the load event- Throws:
DAValidateException- if the entity doesn't existDAException- the DA exception
-