Class Preconditions

java.lang.Object
com.irurueta.authserver.authorization.domain.Preconditions

public final class Preconditions extends Object
Argument checks shared by the domain models. The domain depends on nothing but the JDK, so it cannot use Spring's StringUtils; these helpers keep the null-or-blank branch in one place instead of in every compact constructor.
  • Constructor Details

    • Preconditions

      private Preconditions()
      Not instantiable: a holder of static helpers.
  • Method Details

    • isBlank

      public static boolean isBlank(String value)
      Tells whether a text is missing.
      Parameters:
      value - value to check.
      Returns:
      true when the value is null, empty or only whitespace.
    • requireText

      public static String requireText(String value, String name)
      Rejects a null or blank text.
      Parameters:
      value - value to check.
      name - name of the value, for the message.
      Returns:
      the value, so a check can be used inline.
      Throws:
      IllegalArgumentException - if the value is null, empty or only whitespace.
    • requireTextIfPresent

      public static String requireTextIfPresent(String value, String name)
      Rejects a blank text but accepts a missing one, for an optional value.
      Parameters:
      value - value to check, or null.
      name - name of the value, for the message.
      Returns:
      the value.
      Throws:
      IllegalArgumentException - if the value is empty or only whitespace.