Interface PrimitiveBooleanValidator
- All Superinterfaces:
ValidatorComponent<PrimitiveBooleanValidator,
Boolean>
public interface PrimitiveBooleanValidator
extends ValidatorComponent<PrimitiveBooleanValidator,Boolean>
Validates the state of a
boolean
.-
Method Summary
Modifier and TypeMethodDescriptionboolean
getValue()
Returns the value that is being validated.boolean
getValueOrDefault
(boolean defaultValue) Returns the value that is being validated.isEqualTo
(boolean expected) Ensures that the value is equal toexpected
.Ensures that the value is equal toexpected
.isFalse()
Ensures that the value isfalse
.isNotEqualTo
(boolean unwanted) Ensures that the value is not equal tounwanted
.isNotEqualTo
(boolean unwanted, String name) Ensures that the value is not equal tounwanted
.isTrue()
Ensures that the value istrue
.Methods declared in interface com.github.cowwoc.requirements10.java.validator.component.ValidatorComponent
and, elseGetFailures, elseThrow, getContext, getContextAsString, getName, getValueOrDefault, validationFailed, withContext
-
Method Details
-
getValue
boolean getValue()Returns the value that is being validated.- Returns:
- the value
- Throws:
IllegalStateException
- if a previous validation failed
-
getValueOrDefault
boolean getValueOrDefault(boolean 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
-
isTrue
PrimitiveBooleanValidator isTrue()Ensures that the value istrue
.- Returns:
- this
- Throws:
IllegalArgumentException
- if the value isfalse
-
isFalse
PrimitiveBooleanValidator isFalse()Ensures that the value isfalse
.- Returns:
- this
- Throws:
IllegalArgumentException
- if the value istrue
-
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
is nullIllegalArgumentException
- 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
is nullIllegalArgumentException
- 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
-