Class StringMediator
java.lang.Object
ch.nolix.base.validation.base.AbstractMediator
ch.nolix.base.validation.object.AbstractObjectMediator<String>
ch.nolix.base.validation.object.StringMediator
- Direct Known Subclasses:
ExtendedStringMediator
A
StringMediator is a AbstractMediator for an argument that
is a String. A StringMediator is not mutable.- Author:
- Silvan Wyss
-
Field Summary
Fields inherited from class AbstractMediator
DEFAULT_ARGUMENT_NAME -
Method Summary
Modifier and TypeMethodDescriptionstatic StringMediatorforArgument(String argument) voidhasLength(int length) voidisEmpty()voidvoidvoidisNotLongerThan(int maxLength) voidisNotShorterThan(int minLength) voidvoidstartsWith(String prefix) Methods inherited from class AbstractObjectMediator
fulfills, hasSameStringRepresentationAs, hasStringRepresentation, is, isEqualTo, isNot, isNotEqualTo, isNotNull, isNull, isOfType
-
Method Details
-
forArgument
- Parameters:
argument-- Returns:
- a new
StringMediatorfor the given argument.
-
hasLength
public void hasLength(int length) - Parameters:
length-- Throws:
RuntimeException- if the given length is negative.RuntimeException- if the argument of the currentStringMediatoris null.RuntimeException- if the argument of the currentStringMediatordoes not have the given length.
-
isEmpty
public void isEmpty()- Throws:
RuntimeException- if the argument of the currentStringMediatoris null.NonEmptyArgumentException- if the argument of the currentStringMediatoris not empty.
-
isNotEmpty
public void isNotEmpty()- Throws:
RuntimeException- if the argument of the currentStringMediatoris null.RuntimeException- if the argument of the currentStringMediatoris empty.
-
isNotBlank
public void isNotBlank()- Throws:
RuntimeException- if the argument of the currentStringMediatoris null.RuntimeException- if the argument of the currentStringMediatoris blank.
-
isNotLongerThan
public void isNotLongerThan(int maxLength) - Parameters:
maxLength-- Throws:
RuntimeException- if the argument of the currentStringMediatoris null.RuntimeException- if the argument of the currentStringMediatoris longer than the given max length says.
-
isNotShorterThan
public void isNotShorterThan(int minLength) - Parameters:
minLength-- Throws:
RuntimeException- if the argument of the currentStringMediatoris null.RuntimeException- if the argument of the currentStringMediatoris shorter than the given min length says.
-
matches
- Parameters:
regularExpression-- Throws:
RuntimeException- if the argument of the currentStringMediatordoes not match the given regularExpression.
-
startsWith
- Parameters:
prefix-- Throws:
RuntimeException- if the given prefix is null.RuntimeException- if the argument of the currentStringMediatoris null.RuntimeException- if the argument of the currentStringMediatordoes not start with the given prefix.
-