Interface PrimitiveByteValidator
- All Superinterfaces:
ComparableComponent<PrimitiveByteValidator,,Byte> NegativeNumberComponent<PrimitiveByteValidator>,PositiveNumberComponent<PrimitiveByteValidator>,ValidatorComponent<PrimitiveByteValidator,,Byte> ZeroNumberComponent<PrimitiveByteValidator>
public interface PrimitiveByteValidator
extends ValidatorComponent<PrimitiveByteValidator,Byte>, NegativeNumberComponent<PrimitiveByteValidator>, ZeroNumberComponent<PrimitiveByteValidator>, PositiveNumberComponent<PrimitiveByteValidator>, ComparableComponent<PrimitiveByteValidator,Byte>
Validates the state of a
byte.-
Method Summary
Modifier and TypeMethodDescriptionbytegetValue()Returns the value that is being validated.bytegetValueOrDefault(byte defaultValue) Returns the value that is being validated.isBetween(byte minimum, boolean minimumIsInclusive, byte maximum, boolean maximumIsInclusive) Ensures that the value is within a range.isBetween(byte minimumInclusive, byte maximumExclusive) Ensures that the value is within a range.isEqualTo(byte expected) Ensures that the value is equal toexpected.Ensures that the value is equal toexpected.isGreaterThan(byte minimumExclusive) Ensures that the value is greater than a lower bound.isGreaterThan(byte minimumExclusive, String name) Ensures that the value is greater than a lower bound.isGreaterThanOrEqualTo(byte minimumInclusive) Ensures that the value is greater than or equal to a minimum value.isGreaterThanOrEqualTo(byte minimumInclusive, String name) Ensures that the value is greater than or equal a minimum value.isLessThan(byte maximumExclusive) Ensures that the value is less than an upper bound.isLessThan(byte maximumExclusive, String name) Ensures that the value is less than an upper bound.isLessThanOrEqualTo(byte maximumInclusive) Ensures that the value is less than or equal to a maximum value.isLessThanOrEqualTo(byte maximumInclusive, String name) Ensures that the value is less than or equal to a maximum value.isMultipleOf(byte factor) Ensures that the value is a multiple offactor.isMultipleOf(byte factor, String name) Ensures that the value is a multiple offactor.isNotEqualTo(byte unwanted) Ensures that the value is not equal tounwanted.isNotEqualTo(byte unwanted, String name) Ensures that the value is not equal tounwanted.isNotMultipleOf(byte factor) Ensures that the value is not a multiple offactor.isNotMultipleOf(byte factor, String name) Ensures that the value is not a multiple offactor.Methods declared in interface com.github.cowwoc.requirements10.java.validator.component.ComparableComponent
isBetween, isBetween, isGreaterThan, isGreaterThan, isGreaterThanOrEqualTo, isGreaterThanOrEqualTo, isLessThan, isLessThan, isLessThanOrEqualTo, isLessThanOrEqualToMethods declared in interface com.github.cowwoc.requirements10.java.validator.component.NegativeNumberComponent
isNegative, isNotNegativeMethods declared in interface com.github.cowwoc.requirements10.java.validator.component.PositiveNumberComponent
isNotPositive, isPositiveMethods declared in interface com.github.cowwoc.requirements10.java.validator.component.ValidatorComponent
and, elseGetFailures, elseThrow, getContext, getContextAsString, getName, getValueOrDefault, validationFailed, withContextMethods declared in interface com.github.cowwoc.requirements10.java.validator.component.ZeroNumberComponent
isNotZero, isZero
-
Method Details
-
getValue
byte getValue()Returns the value that is being validated.- Returns:
- the value
- Throws:
IllegalStateException- if a previous validation failed
-
getValueOrDefault
byte getValueOrDefault(byte defaultValue) Returns the value that is being validated.- Parameters:
defaultValue- the fallback value in case of a validation failure- Returns:
- the value, or
defaultValueif 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- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis 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- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is equal to
unwanted
-
isLessThan
Ensures that the value is less than an upper bound.- Parameters:
maximumExclusive- the exclusive upper bound- Returns:
- this
- Throws:
IllegalArgumentException- if the value is greater than or equal tomaximumExclusive
-
isLessThan
Ensures that the value is less than an upper bound.- Parameters:
maximumExclusive- the exclusive upper boundname- the name of the upper bound- Returns:
- this
- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is greater than or equal to
maximumExclusive
-
isLessThanOrEqualTo
Ensures that the value is less than or equal to a maximum value.- Parameters:
maximumInclusive- the inclusive upper value- Returns:
- this
- Throws:
IllegalArgumentException- if the value is greater thanmaximumInclusive
-
isLessThanOrEqualTo
Ensures that the value is less than or equal to a maximum value.- Parameters:
maximumInclusive- the maximum valuename- the name of the maximum value- Returns:
- this
- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is greater than
maximumInclusive
-
isGreaterThanOrEqualTo
Ensures that the value is greater than or equal to a minimum value.- Parameters:
minimumInclusive- the minimum value- Returns:
- this
- Throws:
IllegalArgumentException- if the value is less thanminimumInclusive
-
isGreaterThanOrEqualTo
Ensures that the value is greater than or equal a minimum value.- Parameters:
minimumInclusive- the minimum valuename- the name of the minimum value- Returns:
- this
- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is less than
minimumInclusive
-
isGreaterThan
Ensures that the value is greater than a lower bound.- Parameters:
minimumExclusive- the exclusive lower bound- Returns:
- this
- Throws:
IllegalArgumentException- if the value is less than or equal tominimumExclusive
-
isGreaterThan
Ensures that the value is greater than a lower bound.- Parameters:
minimumExclusive- the exclusive lower boundname- the name of the lower bound- Returns:
- this
- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is less or equal to
minimumExclusive
-
isBetween
Ensures that the value is within a range.- Parameters:
minimumInclusive- the lower bound of the range (inclusive)maximumExclusive- the upper bound of the range (exclusive)- Returns:
- this
- Throws:
IllegalArgumentException- if:minimumInclusiveis greater thanmaximumExclusive- the value is greater than or equal to
maximumExclusive
-
isBetween
PrimitiveByteValidator isBetween(byte minimum, boolean minimumIsInclusive, byte maximum, boolean maximumIsInclusive) Ensures that the value is within a range.- Parameters:
minimum- the lower bound of the rangeminimumIsInclusive-trueif the lower bound of the range is inclusivemaximum- the upper bound of the rangemaximumIsInclusive-trueif the upper bound of the range is inclusive- Returns:
- this
- Throws:
IllegalArgumentException- if:minimumis greater thanmaximumminimumIsInclusiveistrueand the value is less thanminimumminimumIsInclusiveisfalseand the value is less than or equal tominimummaximumIsInclusiveistrueand the value is greater thanmaximummaximumIsInclusiveisfalseand the value is greater than or equal tomaximum
-
isMultipleOf
Ensures that the value is a multiple offactor.- Parameters:
factor- the number being multiplied- Returns:
- this
- Throws:
IllegalArgumentException- if the value is not a multiple offactor
-
isMultipleOf
Ensures that the value is a multiple offactor.- Parameters:
factor- the number being multipliedname- the name of the factor- Returns:
- this
- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is not a multiple of
factor
-
isNotMultipleOf
Ensures that the value is not a multiple offactor.- Parameters:
factor- the number being multiplied- Returns:
- this
- Throws:
IllegalArgumentException- if the value is a multiple offactor
-
isNotMultipleOf
Ensures that the value is not a multiple offactor.- Parameters:
factor- the number being multipliedname- the name of the factor- Returns:
- this
- Throws:
NullPointerException- ifnameis nullIllegalArgumentException- if:nameis emptynamecontains whitespacenameis already in use by the value being validated or the validator context- the value is a multiple of
factor
-