Interface PrimitiveIntegerComponent<S>
- Type Parameters:
S
- the type of validator
- All Known Subinterfaces:
PrimitiveIntegerValidator
,PrimitiveUnsignedIntegerValidator
public interface PrimitiveIntegerComponent<S>
Validates the state of an
int
.-
Method Summary
Modifier and TypeMethodDescriptionint
getValue()
Returns the value that is being validated.int
getValueOrDefault
(int defaultValue) Returns the value that is being validated.isEqualTo
(int expected) Ensures that the value is equal toexpected
.Ensures that the value is equal toexpected
.isNotEqualTo
(int unwanted) Ensures that the value is not equal tounwanted
.isNotEqualTo
(int unwanted, String name) Ensures that the value is not equal tounwanted
.
-
Method Details
-
getValue
int getValue()Returns the value that is being validated.- Returns:
- the value
- Throws:
IllegalStateException
- if a previous validation failed
-
getValueOrDefault
int getValueOrDefault(int defaultValue) Returns the value that is being validated.- Parameters:
defaultValue
- the fallback value in case of a validation failure- Returns:
- the value, or
defaultValue
if a previous validation failed
-
isEqualTo
Ensures that the value is equal toexpected
.- Parameters:
expected
- the expected value- Returns:
- this
- Throws:
IllegalArgumentException
- if the value is not equal toexpected
-
isEqualTo
Ensures that the value is equal toexpected
.- Parameters:
expected
- the expected valuename
- the name of the expected value- Returns:
- this
- Throws:
NullPointerException
- ifname
isnull
IllegalArgumentException
- if:name
is emptyname
contains whitespacename
is already in use by the value being validated or the validator context- the value is not equal to
expected
-
isNotEqualTo
Ensures that the value is not equal tounwanted
.- Parameters:
unwanted
- the value to compare to- Returns:
- this
- Throws:
IllegalArgumentException
- if the value is equal tounwanted
-
isNotEqualTo
Ensures that the value is not equal tounwanted
.- Parameters:
unwanted
- the value to compare toname
- the name of the other value- Returns:
- this
- Throws:
NullPointerException
- ifname
isnull
IllegalArgumentException
- if:name
is emptyname
contains whitespacename
is already in use by the value being validated or the validator context- the value is equal to
unwanted
-