public class StringLengthConstraint extends Object implements ParameterConstraint<String>
StringParameter
.Modifier and Type | Field and Description |
---|---|
(package private) int |
maxlength
Maximum length
|
(package private) int |
minlength
Minimum length
|
Constructor and Description |
---|
StringLengthConstraint(int minlength,
int maxlength)
Constructor with minimum and maximum length.
|
Modifier and Type | Method and Description |
---|---|
String |
getDescription(String parameterName)
Returns a description of this constraint.
|
void |
test(String t)
Checks if the given string value of the string parameter is within the
length restrictions.
|
public StringLengthConstraint(int minlength, int maxlength)
minlength
- Minimum length, may be 0 for no limitmaxlength
- Maximum length, may be -1 for no limitpublic void test(String t) throws ParameterException
test
in interface ParameterConstraint<String>
t
- Value to be checked whether or not it fulfills the underlying
parameter constraint.ParameterException
- if the parameter to be tested does not
fulfill the parameter constraintpublic String getDescription(String parameterName)
ParameterConstraint
getDescription
in interface ParameterConstraint<String>
parameterName
- the name of the parameter this constraint is used for