Class Assert.StringAsserter
java.lang.Object
tech.jhipster.lite.shared.error.domain.Assert.StringAsserter
- Enclosing class:
Assert
Asserter dedicated to
String assertions-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionmatchesPattern(Pattern pattern) Ensure that the given input value matches the given pattern<X extends RuntimeException>
Assert.StringAssertermatchesPatternOrThrow(Pattern pattern, Supplier<X> exceptionSupplier) Ensure that the given input value matches the given patternmaxLength(int length) Ensure that the given input value is not over the given lengthminLength(int length) Ensure that the input value is at least of the given lengthnotBlank()Ensure that the value is not blank (null, empty or only whitespace)notNull()Ensure that the value is not nullEnsure that the value does not contain whitespace
-
Field Details
-
PATTERN_SPACE
-
-
Method Details
-
notNull
Ensure that the value is not null- Returns:
- The current asserter
- Throws:
MissingMandatoryValueException- if the value is null
-
notBlank
Ensure that the value is not blank (null, empty or only whitespace)- Returns:
- The current asserter
- Throws:
MissingMandatoryValueException- if the value is blank
-
noWhitespace
Ensure that the value does not contain whitespace- Returns:
- The current asserter
- Throws:
MissingMandatoryValueException- if the value contain whitespace
-
minLength
Ensure that the input value is at least of the given length- Parameters:
length- inclusive min length of theString- Returns:
- The current asserter
- Throws:
MissingMandatoryValueException- if the expected length is strictly positive and the value is nullStringTooShortException- if the value is shorter than min length
-
maxLength
Ensure that the given input value is not over the given length- Parameters:
length- inclusive max length of theString- Returns:
- The current asserter
- Throws:
StringTooLongException- if the value is longer than the max length
-
matchesPattern
Ensure that the given input value matches the given pattern- Parameters:
pattern- pattern of theString- Returns:
- The current asserter
- Throws:
NotMatchingExpectedPatternException- if the value does not match the provided pattern
-
matchesPatternOrThrow
public <X extends RuntimeException> Assert.StringAsserter matchesPatternOrThrow(Pattern pattern, Supplier<X> exceptionSupplier) Ensure that the given input value matches the given pattern- Parameters:
pattern- pattern of theStringexceptionSupplier- supplier of the exception to throw if the value does not match the pattern- Returns:
- The current asserter
- Throws:
X- provided exception if the value does not match the provided pattern
-