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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcheckOptionalString(String value, int maxLength) Checks whethervaluevalidates as an optional string.static voidcheckRequiredString(String value) Checks whethervaluevalidates as a required string.static voidcheckRequiredString(String value, int maxLength) Checks whethervaluevalidates as a required string.
-
Constructor Details
-
CustomPreconditions
public CustomPreconditions()
-
-
Method Details
-
checkRequiredString
Checks whethervaluevalidates as a required string. This method duplicates the logic of theRequiredStringannotation and exists only to support cases where annotations cannot be used.- Parameters:
value- the value to check- Throws:
IllegalArgumentException- ifvalueis blank
-
checkRequiredString
Checks whethervaluevalidates as a required string. This method duplicates the logic of theRequiredStringannotation and exists only to support cases where annotations cannot be used.- Parameters:
value- the value to checkmaxLength- the maximum allowed string length- Throws:
IllegalArgumentException- ifvalueis blank or longer thanmaxLengthcharacters
-
checkOptionalString
Checks whethervaluevalidates as an optional string. This method duplicates the logic of theOptionalStringannotation and exists only to support cases where annotations cannot be used.- Parameters:
value- the value to checkmaxLength- the maximum allowed string length- Throws:
IllegalArgumentException- ifvaluetrims to the empty string or longer thanmaxLengthcharacters.nullis allowed.
-