Class Preconditions
java.lang.Object
com.irurueta.authserver.authorization.domain.Preconditions
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 Summary
ConstructorsModifierConstructorDescriptionprivateNot instantiable: a holder of static helpers. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTells whether a text is missing.static StringrequireText(String value, String name) Rejects a null or blank text.static StringrequireTextIfPresent(String value, String name) Rejects a blank text but accepts a missing one, for an optional value.
-
Constructor Details
-
Preconditions
private Preconditions()Not instantiable: a holder of static helpers.
-
-
Method Details
-
isBlank
Tells whether a text is missing.- Parameters:
value- value to check.- Returns:
truewhen the value isnull, empty or only whitespace.
-
requireText
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 isnull, empty or only whitespace.
-
requireTextIfPresent
Rejects a blank text but accepts a missing one, for an optional value.- Parameters:
value- value to check, ornull.name- name of the value, for the message.- Returns:
- the value.
- Throws:
IllegalArgumentException- if the value is empty or only whitespace.
-