public final class DoubleRequirementsImpl extends Object implements DoubleRequirements
| Modifier and Type | Method and Description |
|---|---|
DoubleRequirements |
addContext(String key,
Object value)
Appends contextual information to the exception message.
|
DoubleRequirements |
isEqualTo(Double value)
Ensures that the parameter is equal to a value.
|
DoubleRequirements |
isEqualTo(Double value,
String name)
Ensures that the parameter is equal to a variable.
|
DoubleRequirements |
isFinite()
Ensures that the parameter is finite.
|
DoubleRequirements |
isGreaterThan(Double value)
Ensures that the parameter is greater than a constant.
|
DoubleRequirements |
isGreaterThan(Double value,
String name)
Ensures that the parameter is greater than a variable.
|
DoubleRequirements |
isGreaterThanOrEqualTo(Double value)
Ensures that the parameter is greater than or bigger than a constant.
|
DoubleRequirements |
isGreaterThanOrEqualTo(Double value,
String name)
Ensures that the parameter is greater than or bigger than a variable.
|
DoubleRequirements |
isIn(Collection<Double> collection)
Ensures that a collection contains the parameter.
|
DoubleRequirements |
isIn(Double first,
Double last)
Ensures that the parameter is within range.
|
DoubleRequirements |
isIn(Range<Double> range)
Deprecated.
|
DoubleRequirements |
isInstanceOf(Class<?> type)
Ensures that the parameter is an instance of a class.
|
DoubleRequirements |
isLessThan(Double value)
Ensures that the parameter is less than a constant.
|
DoubleRequirements |
isLessThan(Double value,
String name)
Ensures that the parameter is less than the value of a variable.
|
DoubleRequirements |
isLessThanOrEqualTo(Double value)
Ensures that the parameter is less than or equal to a constant.
|
DoubleRequirements |
isLessThanOrEqualTo(Double value,
String name)
Ensures that the parameter is less than or equal to a variable.
|
DoubleRequirements |
isNegative()
Ensures that the parameter is negative.
|
DoubleRequirements |
isNotEqualTo(Double value)
Ensures that the parameter is not equal to a value.
|
DoubleRequirements |
isNotEqualTo(Double value,
String name)
Ensures that the parameter is not equal to a variable.
|
DoubleRequirements |
isNotFinite()
Ensures that the parameter is not finite.
|
DoubleRequirements |
isNotNegative()
Ensures that the parameter is not negative.
|
DoubleRequirements |
isNotNull()
Ensures that the parameter is not null.
|
DoubleRequirements |
isNotNumber()
Ensures that the parameter is not a number.
|
DoubleRequirements |
isNotPositive()
Ensures that the parameter is not positive.
|
DoubleRequirements |
isNotZero()
Ensures that the parameter is not zero.
|
DoubleRequirements |
isNull()
Ensures that the parameter is null.
|
DoubleRequirements |
isNumber()
Ensures that the parameter is a number.
|
DoubleRequirements |
isolate(Consumer<DoubleRequirements> consumer)
Verifies requirements without modifying the current instance.
|
DoubleRequirements |
isPositive()
Ensures that the parameter is positive.
|
DoubleRequirements |
isZero()
Ensures that the parameter is zero.
|
DoubleRequirements |
withContext(List<Map.Entry<String,Object>> context)
Sets the contextual information to append to the exception message.
|
DoubleRequirements |
withException(Class<? extends RuntimeException> exception)
Overrides the type of exception that will get thrown if a requirement fails.
|
public DoubleRequirements withException(Class<? extends RuntimeException> exception)
VerifierThe exception class must define the following constructors:
<init>(String message)
<init>(String message, Throwable cause)
withException in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>withException in interface Verifierexception - the type of exception to throw, null to throw the default exception
typepublic DoubleRequirements addContext(String key, Object value)
VerifieraddContext in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>addContext in interface Verifierkey - a keyvalue - a valuepublic DoubleRequirements withContext(List<Map.Entry<String,Object>> context) throws NullPointerException
VerifierwithContext in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>withContext in interface Verifiercontext - the contextual informationNullPointerException - if context is nullpublic DoubleRequirements isNegative() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpiisNegative in interface org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is not negativepublic DoubleRequirements isNotNegative() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpiisNotNegative in interface org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is negativepublic DoubleRequirements isNotPositive() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpiisNotPositive in interface org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is positivepublic DoubleRequirements isNotZero() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpiisNotZero in interface org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is zeropublic DoubleRequirements isPositive() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpiisPositive in interface org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is not positivepublic DoubleRequirements isZero() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpiisZero in interface org.bitbucket.cowwoc.requirements.spi.NumberRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is not zeropublic DoubleRequirements isGreaterThan(Double value, String name) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisGreaterThan in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be greater thanname - the name of the variableNullPointerException - if value or name are nullIllegalArgumentException - if parameter is less than or equal to value;
if name is emptypublic DoubleRequirements isGreaterThan(Double value) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisGreaterThan in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be greater thanNullPointerException - if value is nullIllegalArgumentException - if parameter is less than or equal to valuepublic DoubleRequirements isGreaterThanOrEqualTo(Double value, String name) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisGreaterThanOrEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be greater than or equal toname - the name of the variableNullPointerException - if value or name are nullIllegalArgumentException - if parameter is less than to value; if
name is emptypublic DoubleRequirements isGreaterThanOrEqualTo(Double value) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisGreaterThanOrEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be greater than or equal toNullPointerException - if value is nullIllegalArgumentException - if parameter is less than to valuepublic DoubleRequirements isLessThan(Double value, String name) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisLessThan in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be less thanname - the name of the variableNullPointerException - if value or name are nullIllegalArgumentException - if parameter is greater than or equal to
value; if name is emptypublic DoubleRequirements isLessThan(Double value) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisLessThan in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be less thanNullPointerException - if value is nullIllegalArgumentException - if parameter is greater than or equal to valuepublic DoubleRequirements isLessThanOrEqualTo(Double value, String name) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisLessThanOrEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be less than or equal toname - the name of the variableNullPointerException - if value or name are nullIllegalArgumentException - if parameter is greater than value; if
name is emptypublic DoubleRequirements isLessThanOrEqualTo(Double value) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisLessThanOrEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>value - the value the parameter must be less than or equal toNullPointerException - if value is nullIllegalArgumentException - if parameter is greater than value@Deprecated public DoubleRequirements isIn(Range<Double> range) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisIn in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>range - the rangeNullPointerException - if range is nullIllegalArgumentException - if parameter is not in rangepublic DoubleRequirements isIn(Double first, Double last) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpiisIn in interface org.bitbucket.cowwoc.requirements.spi.ComparableRequirementsSpi<DoubleRequirements,Double>first - the first element in the rangelast - the last element in the rangeNullPointerException - if first or last are nullIllegalArgumentException - if last is less than first; if
parameter is not in rangepublic DoubleRequirements isEqualTo(Double value) throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>value - the value to compare toIllegalArgumentException - if parameter is not equal to valuepublic DoubleRequirements isEqualTo(Double value, String name) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>value - the value to compare toname - the name of the variableNullPointerException - if name is nullIllegalArgumentException - if parameter is not equal to the variable; if
name is emptypublic DoubleRequirements isNotEqualTo(Double value) throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisNotEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>value - the value to compare toIllegalArgumentException - if parameter is equal to valuepublic DoubleRequirements isNotEqualTo(Double value, String name) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisNotEqualTo in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>value - the value to compare toname - the name of the variableNullPointerException - if name is nullIllegalArgumentException - if parameter is equal to the variable; if name
is emptypublic DoubleRequirements isIn(Collection<Double> collection) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisIn in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>collection - a collectionNullPointerException - if collection is nullIllegalArgumentException - if collection does not contain parameterpublic DoubleRequirements isInstanceOf(Class<?> type) throws NullPointerException, IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisInstanceOf in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>type - the class to compare toNullPointerException - if type are nullIllegalArgumentException - if parameter is not an instance of typepublic DoubleRequirements isNull() throws IllegalArgumentException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisNull in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>IllegalArgumentException - if parameter is not nullpublic DoubleRequirements isNotNull() throws NullPointerException
org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpiisNotNull in interface org.bitbucket.cowwoc.requirements.spi.ObjectRequirementsSpi<DoubleRequirements,Double>NullPointerException - if parameter is nullpublic DoubleRequirements isNumber() throws IllegalArgumentException
DoubleRequirementsisNumber in interface DoubleRequirementsIllegalArgumentException - if parameter is not a numberDouble.isNaN()public DoubleRequirements isNotNumber() throws IllegalArgumentException
DoubleRequirementsisNotNumber in interface DoubleRequirementsIllegalArgumentException - if parameter is a numberDouble.isNaN()public DoubleRequirements isFinite() throws IllegalArgumentException
DoubleRequirementsisFinite in interface DoubleRequirementsIllegalArgumentException - if parameter is not finiteDouble.isInfinite()public DoubleRequirements isNotFinite() throws IllegalArgumentException
DoubleRequirementsisNotFinite in interface DoubleRequirementsIllegalArgumentException - if parameter is finiteDouble.isInfinite()public DoubleRequirements isolate(Consumer<DoubleRequirements> consumer)
Isolatable
Map<String, Integer> nameToId = ...;
Requirements.requireThat(nameToId, "nameToId").keySet().contains("John Smith");
Requirements.requireThat(nameToId, "nameToId").values().doesNotContain(0, "RESERVED_ID");
// Can be rewritten as:
Requirements.requireThat(nameToId, "nameToId").
isolate(p -> p.keySet().contains("John Smith")).
isolate(p -> p.values().doesNotContain(0, "RESERVED_ID"));
isolate in interface Isolatable<DoubleRequirements>consumer - the code to execute in isolationCopyright © 2016. All rights reserved.