Class GenericValidator
java.lang.Object
com.bluebell.greenhouse.radicle.validation.GenericValidator
Validator class for method integrity.
- Version:
- 2.0.3
- Author:
- Stephen Prizio
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidvalidateAcceptableYear(int year, String message, Object... values) Validates that the givenIntegeris not greater than the maximum allowable within the app.static voidvalidateDatesAreNotMutuallyExclusive(LocalDateTime compareOne, LocalDateTime compareTwo, String message, Object... values) Validates that the 2 givenLocalDateTimes are valid and don't overlap.static voidvalidateIfAnyResult(Collection<?> collection, String message, Object... values) Validates that the givenCollectionis not empty.static voidvalidateIfSingleResult(Collection<?> collection, String message, Object... values) Validates that the givenCollectiononly contains 1 element.static voidvalidateJsonIntegrity(Object object, String message) Validates if the given json map contains the given keys.static voidvalidateLocalDateFormat(String date, String format, String message, Object... values) Validates if the given date is of the given format.static voidvalidateLocalDateTimeFormat(String date, String format, String message, Object... values) Validates if the given date & time is of the given format.static voidvalidateNonNegativeValue(Number number, String message, Object... values) Validates that the givenNumberis not negative.static voidvalidateNonZeroValue(Number number, String message, Object... values) Validates that the givenNumberis not zero.static voidvalidateParameterIsNotNull(Object param, String message, Object... values) Validates if the given parameter is not null.static voidvalidateStandardParameters(LocalDateTime start, LocalDateTime end, Account account, org.springframework.data.domain.Sort sort) Validates standard trade lookup parameters.static voidvalidateStringParameterIsNotEmpty(String param, String message, Object... values) Validates if the given string parameter is not empty.
-
Method Details
-
validateParameterIsNotNull
Validates if the given parameter is not null.- Parameters:
param- parameter to testmessage- error messagevalues- error message values- Throws:
IllegalParameterException- if parameter is null
-
validateStringParameterIsNotEmpty
-
validateIfSingleResult
public static void validateIfSingleResult(Collection<?> collection, String message, Object... values) Validates that the givenCollectiononly contains 1 element.- Parameters:
collection- collection to testmessage- error messagevalues- error message values- Throws:
NonUniqueItemFoundException- if the collection size is greater than 1
-
validateIfAnyResult
Validates that the givenCollectionis not empty.- Parameters:
collection- collection to testmessage- error messagevalues- error message values- Throws:
NoResultFoundException- if the collection is empty
-
validateDatesAreNotMutuallyExclusive
public static void validateDatesAreNotMutuallyExclusive(LocalDateTime compareOne, LocalDateTime compareTwo, String message, Object... values) Validates that the 2 givenLocalDateTimes are valid and don't overlap.- Parameters:
compareOne- start datecompareTwo- end datemessage- error messagevalues- error message values- Throws:
UnsupportedOperationException- if dates are exclusive
-
validateLocalDateTimeFormat
public static void validateLocalDateTimeFormat(String date, String format, String message, Object... values) Validates if the given date & time is of the given format.- Parameters:
date- date to testformat- date expected formatmessage- error messagevalues- error message values- Throws:
DateTimeException- for bad format
-
validateLocalDateFormat
public static void validateLocalDateFormat(String date, String format, String message, Object... values) Validates if the given date is of the given format.- Parameters:
date- date to testformat- date expected formatmessage- error messagevalues- error message values- Throws:
DateTimeException- for bad format
-
validateJsonIntegrity
Validates if the given json map contains the given keys.- Parameters:
object- objectmessage- error message- Throws:
JsonMissingPropertyException- if the json is missing a required property
-
validateNonNegativeValue
-
validateNonZeroValue
-
validateAcceptableYear
-
validateStandardParameters
public static void validateStandardParameters(LocalDateTime start, LocalDateTime end, Account account, org.springframework.data.domain.Sort sort) Validates standard trade lookup parameters.- Parameters:
start- start dateend- end dateaccount-Accountsort-Sort
-