Package com.atlassian.bitbucket.util
Class CustomPreconditions
java.lang.Object
com.atlassian.bitbucket.util.CustomPreconditions
More precondition checks following the same pattern as Guava's
Preconditions
.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
checkOptionalString
(String value, int maxLength) Checks whethervalue
validates as an optional string.static void
checkRequiredString
(String value) Checks whethervalue
validates as a required string.static void
checkRequiredString
(String value, int maxLength) Checks whethervalue
validates as a required string.
-
Constructor Details
-
CustomPreconditions
public CustomPreconditions()
-
-
Method Details
-
checkRequiredString
Checks whethervalue
validates as a required string. This method duplicates the logic of theRequiredString
annotation and exists only to support cases where annotations cannot be used.- Parameters:
value
- the value to check- Throws:
IllegalArgumentException
- ifvalue
is blank
-
checkRequiredString
Checks whethervalue
validates as a required string. This method duplicates the logic of theRequiredString
annotation and exists only to support cases where annotations cannot be used.- Parameters:
value
- the value to checkmaxLength
- the maximum allowed string length- Throws:
IllegalArgumentException
- ifvalue
is blank or longer thanmaxLength
characters
-
checkOptionalString
Checks whethervalue
validates as an optional string. This method duplicates the logic of theOptionalString
annotation and exists only to support cases where annotations cannot be used.- Parameters:
value
- the value to checkmaxLength
- the maximum allowed string length- Throws:
IllegalArgumentException
- ifvalue
trims to the empty string or longer thanmaxLength
characters.null
is allowed.
-