Class GenericValidator

java.lang.Object
com.bluebell.greenhouse.radicle.validation.GenericValidator

public final class GenericValidator extends Object
Validator class for method integrity.
Version:
2.0.3
Author:
Stephen Prizio
  • Method Details

    • validateParameterIsNotNull

      public static void validateParameterIsNotNull(Object param, String message, Object... values)
      Validates if the given parameter is not null.
      Parameters:
      param - parameter to test
      message - error message
      values - error message values
      Throws:
      IllegalParameterException - if parameter is null
    • validateStringParameterIsNotEmpty

      public static void validateStringParameterIsNotEmpty(String param, String message, Object... values)
      Validates if the given string parameter is not empty.
      Parameters:
      param - parameter to test
      message - error message
      values - error message values
    • validateIfSingleResult

      public static void validateIfSingleResult(Collection<?> collection, String message, Object... values)
      Validates that the given Collection only contains 1 element.
      Parameters:
      collection - collection to test
      message - error message
      values - error message values
      Throws:
      NonUniqueItemFoundException - if the collection size is greater than 1
    • validateIfAnyResult

      public static void validateIfAnyResult(Collection<?> collection, String message, Object... values)
      Validates that the given Collection is not empty.
      Parameters:
      collection - collection to test
      message - error message
      values - 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 given LocalDateTimes are valid and don't overlap.
      Parameters:
      compareOne - start date
      compareTwo - end date
      message - error message
      values - 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 test
      format - date expected format
      message - error message
      values - 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 test
      format - date expected format
      message - error message
      values - error message values
      Throws:
      DateTimeException - for bad format
    • validateJsonIntegrity

      public static void validateJsonIntegrity(Object object, String message)
      Validates if the given json map contains the given keys.
      Parameters:
      object - object
      message - error message
      Throws:
      JsonMissingPropertyException - if the json is missing a required property
    • validateNonNegativeValue

      public static void validateNonNegativeValue(Number number, String message, Object... values)
      Validates that the given Number is not negative.
      Parameters:
      number - Number
      message - error message
      values - error message values
      Throws:
      UnexpectedNegativeValueException - if value is negative
    • validateNonZeroValue

      public static void validateNonZeroValue(Number number, String message, Object... values)
      Validates that the given Number is not zero.
      Parameters:
      number - Number
      message - error message
      values - error message values
      Throws:
      UnexpectedZeroValueException - if value is zero
    • validateAcceptableYear

      public static void validateAcceptableYear(int year, String message, Object... values)
      Validates that the given Integer is not greater than the maximum allowable within the app.
      Parameters:
      year - year value
      message - error message
      values - error message values
    • 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 date
      end - end date
      account - Account
      sort - Sort