Package com.github.cowwoc.requirements
Class DefaultRequirements
java.lang.Object
com.github.cowwoc.requirements.DefaultRequirements
Verifies requirements using the default
configuration
. Any method that exposes
a Requirements
instance is returning an independent copy. Any modifications applied to that
copy are thrown away and do not affect the configuration of this class.
To retain configuration changes, instantiate and reuse the same Requirements
instance across
multiple runs.
Thread-safety: This class is thread-safe.
- See Also:
-
Requirements
JavaRequirements
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Returns true if assertions are enabled for this class.static void
assertThat
(Consumer<Requirements> requirements) Verifies requirements only if assertions are enabled.static <V> V
assertThatAndReturn
(Function<Requirements, V> requirements) Verifies requirements only ifassertions are enabled
.Returns an unmodifiable map to append to the exception message.static String
getContextMessage
(String message) Returns the contextual information associated with this configuration.static boolean
Indicates if stack trace references to this library should be removed.static boolean
Indicates if exceptions should show the difference between the actual and expected values.static com.github.cowwoc.requirements.java.ArrayVerifier<boolean[],
Boolean> requireThat
(boolean[] actual, String name) Verifies the requirements of a primitiveboolean
array.static com.github.cowwoc.requirements.java.PrimitiveBooleanVerifier
requireThat
(boolean actual, String name) Verifies the requirements of aboolean
.static com.github.cowwoc.requirements.java.ArrayVerifier<byte[],
Byte> requireThat
(byte[] actual, String name) Verifies the requirements of a primitivebyte
array.static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Byte>
requireThat
(byte actual, String name) Verifies the requirements of abyte
.static com.github.cowwoc.requirements.java.ArrayVerifier<char[],
Character> requireThat
(char[] actual, String name) Verifies the requirements of a primitivechar
array.static com.github.cowwoc.requirements.java.PrimitiveCharacterVerifier
requireThat
(char actual, String name) Verifies the requirements of achar
.static com.github.cowwoc.requirements.java.ArrayVerifier<double[],
Double> requireThat
(double[] actual, String name) Verifies the requirements of a primitivedouble
array.static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Double>
requireThat
(double actual, String name) Verifies the requirements of adouble
.static com.github.cowwoc.requirements.java.ArrayVerifier<float[],
Float> requireThat
(float[] actual, String name) Verifies the requirements of a primitivefloat
array.static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Float>
requireThat
(float actual, String name) Verifies the requirements of afloat
.static com.github.cowwoc.requirements.java.ArrayVerifier<int[],
Integer> requireThat
(int[] actual, String name) Verifies the requirements of a primitiveint
array.static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Integer>
requireThat
(int actual, String name) Verifies the requirements of anint
.static com.github.cowwoc.requirements.java.ArrayVerifier<long[],
Long> requireThat
(long[] actual, String name) Verifies the requirements of a primitivelong
array.static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Long>
requireThat
(long actual, String name) Verifies the requirements of along
.static com.github.cowwoc.requirements.java.ArrayVerifier<short[],
Short> requireThat
(short[] actual, String name) Verifies the requirements of a primitiveshort
array.static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Short>
requireThat
(short actual, String name) Verifies the requirements of ashort
.static <C extends Collection<E>,
E>
com.github.cowwoc.requirements.java.CollectionVerifier<C,E> requireThat
(C actual, String name) Verifies the requirements of aCollection
.static <E> com.github.cowwoc.requirements.java.ArrayVerifier<E[],
E> requireThat
(E[] actual, String name) Verifies the requirements of anObject
array.static com.github.cowwoc.requirements.java.BooleanVerifier
requireThat
(Boolean actual, String name) Verifies the requirements of aBoolean
.static <T> com.github.cowwoc.requirements.java.ClassVerifier<T>
requireThat
(Class<T> actual, String name) Verifies the requirements of aClass
.static com.github.cowwoc.requirements.java.FloatingPointVerifier<Double>
requireThat
(Double actual, String name) Verifies the requirements of aDouble
.static com.github.cowwoc.requirements.java.FloatingPointVerifier<Float>
requireThat
(Float actual, String name) Verifies the requirements of aFloat
.static com.github.cowwoc.requirements.java.IntegerVerifier<Integer>
requireThat
(Integer actual, String name) Verifies the requirements of anInteger
.static com.github.cowwoc.requirements.java.IntegerVerifier<Long>
requireThat
(Long actual, String name) Verifies the requirements of aLong
.static com.github.cowwoc.requirements.java.StringVerifier
requireThat
(String actual, String name) Verifies the requirements of aString
.static com.github.cowwoc.requirements.java.BigDecimalVerifier
requireThat
(BigDecimal actual, String name) Verifies the requirements of aBigDecimal
.static com.github.cowwoc.requirements.java.InetAddressVerifier
requireThat
(InetAddress actual, String name) Verifies the requirements of anInetAddress
.static com.github.cowwoc.requirements.java.UriVerifier
requireThat
(URI actual, String name) Verifies the requirements of aURI
.static com.github.cowwoc.requirements.java.UrlVerifier
requireThat
(URL actual, String name) Verifies the requirements of aURL
.static com.github.cowwoc.requirements.java.PathVerifier
requireThat
(Path actual, String name) Verifies the requirements of aPath
.static <K,
V> com.github.cowwoc.requirements.java.MapVerifier<K, V> requireThat
(Map<K, V> actual, String name) Verifies the requirements of aMap
.static com.github.cowwoc.requirements.java.OptionalVerifier
requireThat
(Optional<?> actual, String name) Verifies the requirements of anOptional
.static <L extends List<E>,
E>
com.github.cowwoc.requirements.java.ListVerifier<L,E> requireThat
(L actual, String name) Verifies the requirements of aList
.static <T> com.github.cowwoc.requirements.java.ObjectVerifier<T>
requireThat
(T actual, String name) Verifies the requirements of anObject
.static String
Returns theString
representation of an object.static com.github.cowwoc.requirements.java.ArrayValidator<boolean[],
Boolean> validateThat
(boolean[] actual, String name) Validates the requirements of a primitiveboolean
array.static com.github.cowwoc.requirements.java.PrimitiveBooleanValidator
validateThat
(boolean actual, String name) Validates the requirements of aboolean
.static com.github.cowwoc.requirements.java.ArrayValidator<byte[],
Byte> validateThat
(byte[] actual, String name) Validates the requirements of a primitivebyte
array.static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Byte>
validateThat
(byte actual, String name) Validates the requirements of abyte
.static com.github.cowwoc.requirements.java.ArrayValidator<char[],
Character> validateThat
(char[] actual, String name) Validates the requirements of a primitivechar
array.static com.github.cowwoc.requirements.java.PrimitiveCharacterValidator
validateThat
(char actual, String name) Validates the requirements of achar
.static com.github.cowwoc.requirements.java.ArrayValidator<double[],
Double> validateThat
(double[] actual, String name) Validates the requirements of a primitivedouble
array.static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Double>
validateThat
(double actual, String name) Validates the requirements of adouble
.static com.github.cowwoc.requirements.java.ArrayValidator<float[],
Float> validateThat
(float[] actual, String name) Validates the requirements of a primitivefloat
array.static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Float>
validateThat
(float actual, String name) Validates the requirements of afloat
.static com.github.cowwoc.requirements.java.ArrayValidator<int[],
Integer> validateThat
(int[] actual, String name) Validates the requirements of a primitiveint
array.static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Integer>
validateThat
(int actual, String name) Validates the requirements of anint
.static com.github.cowwoc.requirements.java.ArrayValidator<long[],
Long> validateThat
(long[] actual, String name) Validates the requirements of a primitivelong
array.static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Long>
validateThat
(long actual, String name) Validates the requirements of along
.static com.github.cowwoc.requirements.java.ArrayValidator<short[],
Short> validateThat
(short[] actual, String name) Validates the requirements of a primitiveshort
array.static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Short>
validateThat
(short actual, String name) Validates the requirements of ashort
.static <C extends Collection<E>,
E>
com.github.cowwoc.requirements.java.CollectionValidator<C,E> validateThat
(C actual, String name) Validates the requirements of aCollection
.static <E> com.github.cowwoc.requirements.java.ArrayValidator<E[],
E> validateThat
(E[] actual, String name) Validates the requirements of anObject
array.static com.github.cowwoc.requirements.java.BooleanValidator
validateThat
(Boolean actual, String name) Validates the requirements of aBoolean
.static <T> com.github.cowwoc.requirements.java.ClassValidator<T>
validateThat
(Class<T> actual, String name) Validates the requirements of aClass
.static com.github.cowwoc.requirements.java.FloatingPointValidator<Double>
validateThat
(Double actual, String name) Validates the requirements of aDouble
.static com.github.cowwoc.requirements.java.FloatingPointValidator<Float>
validateThat
(Float actual, String name) Validates the requirements of aFloat
.static com.github.cowwoc.requirements.java.IntegerValidator<Integer>
validateThat
(Integer actual, String name) Validates the requirements of anInteger
.static com.github.cowwoc.requirements.java.IntegerValidator<Long>
validateThat
(Long actual, String name) Validates the requirements of aLong
.static com.github.cowwoc.requirements.java.StringValidator
validateThat
(String actual, String name) Validates the requirements of aString
.static com.github.cowwoc.requirements.java.BigDecimalValidator
validateThat
(BigDecimal actual, String name) Validates the requirements of aBigDecimal
.static com.github.cowwoc.requirements.java.InetAddressValidator
validateThat
(InetAddress actual, String name) Validates the requirements of anInetAddress
.static com.github.cowwoc.requirements.java.UriValidator
validateThat
(URI actual, String name) Validates the requirements of aURI
.static com.github.cowwoc.requirements.java.UrlValidator
validateThat
(URL actual, String name) Validates the requirements of aURL
.static com.github.cowwoc.requirements.java.PathValidator
validateThat
(Path actual, String name) Validates the requirements of aPath
.static <K,
V> com.github.cowwoc.requirements.java.MapValidator<K, V> validateThat
(Map<K, V> actual, String name) Validates the requirements of aMap
.static com.github.cowwoc.requirements.java.OptionalValidator
validateThat
(Optional<?> actual, String name) Validates the requirements of anOptional
.static <L extends List<E>,
E>
com.github.cowwoc.requirements.java.ListValidator<L,E> validateThat
(L actual, String name) Validates the requirements of aList
.static <T> com.github.cowwoc.requirements.java.ObjectValidator<T>
validateThat
(T actual, String name) Validates the requirements of anObject
.static Requirements
Indicates thatassertThat()
shouldn't do anything.static Requirements
Indicates thatassertThat()
should verify requirements.static Requirements
Indicates that stack trace references to this library should be removed.static Requirements
withConfiguration
(com.github.cowwoc.requirements.java.Configuration configuration) Replaces the configuration.static Requirements
withContext
(String name, Object value) Adds or updates contextual information associated with the exception message.static Requirements
withDiff()
Indicates that exceptions should show the difference between the actual and expected values.static Requirements
Indicates that stack trace references to this library should be kept.static Requirements
Indicates that exceptions should not show the difference between the actual and expected values.static <T> Requirements
withoutStringConverter
(Class<T> type) Indicates that an object'stoString()
method should be used to convert it to a String.static <T> Requirements
withStringConverter
(Class<T> type, Function<T, String> converter) Indicates that a function should be used to convert an object to a String.
-
Method Details
-
assertionsAreEnabled
public static boolean assertionsAreEnabled()Returns true if assertions are enabled for this class.- Returns:
- true if assertions are enabled for this class
-
withAssertionsEnabled
Indicates thatassertThat()
should verify requirements.- Returns:
- a new
Requirements
object that operates independently of the original instance
-
withAssertionsDisabled
Indicates thatassertThat()
shouldn't do anything.- Returns:
- a new
Requirements
object that operates independently of the original instance
-
isDiffEnabled
public static boolean isDiffEnabled()Indicates if exceptions should show the difference between the actual and expected values.- Returns:
- true by default
-
withDiff
Indicates that exceptions should show the difference between the actual and expected values.- Returns:
- a new
Requirements
object that operates independently of the original instance
-
withoutDiff
Indicates that exceptions should not show the difference between the actual and expected values.- Returns:
- a new
Requirements
object that operates independently of the original instance
-
isCleanStackTrace
public static boolean isCleanStackTrace()Indicates if stack trace references to this library should be removed.- Returns:
true
by default- See Also:
-
withCleanStackTrace
Indicates that stack trace references to this library should be removed.- Returns:
- a new
Requirements
object that operates independently of the original instance - See Also:
-
withoutCleanStackTrace
Indicates that stack trace references to this library should be kept.- Returns:
- a new
Requirements
object that operates independently of the original instance - See Also:
-
getContext
Returns an unmodifiable map to append to the exception message.- Returns:
- an empty map by default
- See Also:
-
withContext
Adds or updates contextual information associated with the exception message. Overrides any values associated with thename
at theThreadRequirements
level.- Parameters:
name
- the name of the parametervalue
- the value of the parameter- Returns:
- a new
Requirements
object that operates independently of the original instance - Throws:
NullPointerException
- ifname
is null
-
getContextMessage
Returns the contextual information associated with this configuration.- Parameters:
message
- the exception message (null
if absent)- Returns:
- the contextual information associated with this configuration
-
toString
Returns theString
representation of an object. By default, custom handlers are provided for arrays,Integer
,Long
,BigDecimal
, andPath
.- Parameters:
value
- a value- Returns:
- the
String
representation of the value - See Also:
-
withStringConverter
Indicates that a function should be used to convert an object to a String.Please note that
type
must be an exact match (e.g. configuring a converter forSet
will not match values of typeHashSet
).- Type Parameters:
T
- the type of object being converted- Parameters:
type
- the type of object being converted (non-primitive arrays are mapped toObject[].class
)converter
- a function that converts an object of the specified type to a String- Returns:
- a new
Requirements
object that operates independently of the original instance - Throws:
NullPointerException
- if any of the arguments are null
-
withoutStringConverter
Indicates that an object'stoString()
method should be used to convert it to a String.- Type Parameters:
T
- the type of object being converted- Parameters:
type
- the type of object being converted- Returns:
- a new
Requirements
object that operates independently of the original instance - Throws:
NullPointerException
- iftype
is null
-
withConfiguration
public static Requirements withConfiguration(com.github.cowwoc.requirements.java.Configuration configuration) Replaces the configuration.- Parameters:
configuration
- a new configuration- Returns:
- a new
Requirements
object that operates independently of the original instance - Throws:
NullPointerException
- ifconfiguration
is null
-
assertThatAndReturn
Verifies requirements only ifassertions are enabled
.- Type Parameters:
V
- the return value of the operation- Parameters:
requirements
- the requirements to verify- Returns:
- the return value of the operation, or
null
if assertions are disabled - Throws:
NullPointerException
- ifrequirements
is null- See Also:
-
assertThat
Verifies requirements only if assertions are enabled.- Parameters:
requirements
- the requirements to verify- Throws:
NullPointerException
- ifrequirements
is null- See Also:
-
requireThat
public static <T> com.github.cowwoc.requirements.java.ObjectVerifier<T> requireThat(T actual, String name) Verifies the requirements of anObject
.- Type Parameters:
T
- the type of the value- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <T> com.github.cowwoc.requirements.java.ObjectValidator<T> validateThat(T actual, String name) Validates the requirements of anObject
.- Type Parameters:
T
- the type of the value- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <C extends Collection<E>,E> com.github.cowwoc.requirements.java.CollectionVerifier<C,E> requireThat(C actual, String name) Verifies the requirements of aCollection
.- Type Parameters:
C
- the type of the collectionE
- the type of elements in the collection- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <C extends Collection<E>,E> com.github.cowwoc.requirements.java.CollectionValidator<C,E> validateThat(C actual, String name) Validates the requirements of aCollection
.- Type Parameters:
C
- the type of the collectionE
- the type of elements in the collection- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <L extends List<E>,E> com.github.cowwoc.requirements.java.ListVerifier<L,E> requireThat(L actual, String name) Verifies the requirements of aList
.- Type Parameters:
L
- the type of the listE
- the type of elements in the list- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <L extends List<E>,E> com.github.cowwoc.requirements.java.ListValidator<L,E> validateThat(L actual, String name) Validates the requirements of aList
.- Type Parameters:
L
- the type of the listE
- the type of elements in the list- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<byte[],Byte> requireThat(byte[] actual, String name) Verifies the requirements of a primitivebyte
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<byte[],Byte> validateThat(byte[] actual, String name) Validates the requirements of a primitivebyte
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<short[],Short> requireThat(short[] actual, String name) Verifies the requirements of a primitiveshort
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<short[],Short> validateThat(short[] actual, String name) Validates the requirements of a primitiveshort
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<int[],Integer> requireThat(int[] actual, String name) Verifies the requirements of a primitiveint
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<int[],Integer> validateThat(int[] actual, String name) Validates the requirements of a primitiveint
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<long[],Long> requireThat(long[] actual, String name) Verifies the requirements of a primitivelong
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<long[],Long> validateThat(long[] actual, String name) Validates the requirements of a primitivelong
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<float[],Float> requireThat(float[] actual, String name) Verifies the requirements of a primitivefloat
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<float[],Float> validateThat(float[] actual, String name) Validates the requirements of a primitivefloat
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<double[],Double> requireThat(double[] actual, String name) Verifies the requirements of a primitivedouble
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<double[],Double> validateThat(double[] actual, String name) Validates the requirements of a primitivedouble
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<boolean[],Boolean> requireThat(boolean[] actual, String name) Verifies the requirements of a primitiveboolean
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<boolean[],Boolean> validateThat(boolean[] actual, String name) Validates the requirements of a primitiveboolean
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.ArrayVerifier<char[],Character> requireThat(char[] actual, String name) Verifies the requirements of a primitivechar
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.ArrayValidator<char[],Character> validateThat(char[] actual, String name) Validates the requirements of a primitivechar
array.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <E> com.github.cowwoc.requirements.java.ArrayVerifier<E[],E> requireThat(E[] actual, String name) Verifies the requirements of anObject
array.- Type Parameters:
E
- the type of elements in the array- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <E> com.github.cowwoc.requirements.java.ArrayValidator<E[],E> validateThat(E[] actual, String name) Validates the requirements of anObject
array.- Type Parameters:
E
- the type of elements in the array- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <T extends Comparable<? super T>> com.github.cowwoc.requirements.java.ComparableVerifier<T> requireThat(T actual, String name) Verifies the requirements of aComparable
.- Type Parameters:
T
- the type of objects that the value may be compared to- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <T extends Comparable<? super T>> com.github.cowwoc.requirements.java.ComparableValidator<T> validateThat(T actual, String name) Validates the requirements of aComparable
.- Type Parameters:
T
- the type of objects that the value may be compared to- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Byte> requireThat(byte actual, String name) Verifies the requirements of abyte
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Byte> validateThat(byte actual, String name) Validates the requirements of abyte
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveNumberVerifier<Short> requireThat(short actual, String name) Verifies the requirements of ashort
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveNumberValidator<Short> validateThat(short actual, String name) Validates the requirements of ashort
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Integer> requireThat(int actual, String name) Verifies the requirements of anint
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Integer> validateThat(int actual, String name) Validates the requirements of anint
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.IntegerVerifier<Integer> requireThat(Integer actual, String name) Verifies the requirements of anInteger
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.IntegerValidator<Integer> validateThat(Integer actual, String name) Validates the requirements of anInteger
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveIntegerVerifier<Long> requireThat(long actual, String name) Verifies the requirements of along
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveIntegerValidator<Long> validateThat(long actual, String name) Validates the requirements of along
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.IntegerVerifier<Long> requireThat(Long actual, String name) Verifies the requirements of aLong
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.IntegerValidator<Long> validateThat(Long actual, String name) Validates the requirements of aLong
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Float> requireThat(float actual, String name) Verifies the requirements of afloat
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Float> validateThat(float actual, String name) Validates the requirements of afloat
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointVerifier<Double> requireThat(double actual, String name) Verifies the requirements of adouble
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveFloatingPointValidator<Double> validateThat(double actual, String name) Validates the requirements of adouble
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveBooleanVerifier requireThat(boolean actual, String name) Verifies the requirements of aboolean
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveBooleanValidator validateThat(boolean actual, String name) Validates the requirements of aboolean
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PrimitiveCharacterVerifier requireThat(char actual, String name) Verifies the requirements of achar
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PrimitiveCharacterValidator validateThat(char actual, String name) Validates the requirements of achar
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <T extends Number & Comparable<? super T>> com.github.cowwoc.requirements.java.NumberVerifier<T> requireThat(T actual, String name) Verifies the requirements of aNumber
.- Type Parameters:
T
- the type of the number- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <T extends Number & Comparable<? super T>> com.github.cowwoc.requirements.java.NumberValidator<T> validateThat(T actual, String name) Validates the requirements of aNumber
.- Type Parameters:
T
- the type of the number- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.BooleanVerifier requireThat(Boolean actual, String name) Verifies the requirements of aBoolean
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.BooleanValidator validateThat(Boolean actual, String name) Validates the requirements of aBoolean
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.FloatingPointVerifier<Float> requireThat(Float actual, String name) Verifies the requirements of aFloat
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.FloatingPointValidator<Float> validateThat(Float actual, String name) Validates the requirements of aFloat
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.FloatingPointVerifier<Double> requireThat(Double actual, String name) Verifies the requirements of aDouble
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.FloatingPointValidator<Double> validateThat(Double actual, String name) Validates the requirements of aDouble
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.BigDecimalVerifier requireThat(BigDecimal actual, String name) Verifies the requirements of aBigDecimal
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.BigDecimalValidator validateThat(BigDecimal actual, String name) Validates the requirements of aBigDecimal
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <K,V> com.github.cowwoc.requirements.java.MapVerifier<K,V> requireThat(Map<K, V> actual, String name) Verifies the requirements of aMap
.- Type Parameters:
K
- the type of key in the mapV
- the type of value in the map- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <K,V> com.github.cowwoc.requirements.java.MapValidator<K,V> validateThat(Map<K, V> actual, String name) Validates the requirements of aMap
.- Type Parameters:
K
- the type of key in the mapV
- the type of value in the map- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.PathVerifier requireThat(Path actual, String name) Verifies the requirements of aPath
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.PathValidator validateThat(Path actual, String name) Validates the requirements of aPath
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.StringVerifier requireThat(String actual, String name) Verifies the requirements of aString
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.StringValidator validateThat(String actual, String name) Validates the requirements of aString
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
Verifies the requirements of aURI
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.UriValidator validateThat(URI actual, String name) Validates the requirements of aURI
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
Verifies the requirements of aURL
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.UrlValidator validateThat(URL actual, String name) Validates the requirements of aURL
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static <T> com.github.cowwoc.requirements.java.ClassVerifier<T> requireThat(Class<T> actual, String name) Verifies the requirements of aClass
.- Type Parameters:
T
- the type of class- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static <T> com.github.cowwoc.requirements.java.ClassValidator<T> validateThat(Class<T> actual, String name) Validates the requirements of aClass
.- Type Parameters:
T
- the type of class- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.OptionalVerifier requireThat(Optional<?> actual, String name) Verifies the requirements of anOptional
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.OptionalValidator validateThat(Optional<?> actual, String name) Validates the requirements of anOptional
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
requireThat
public static com.github.cowwoc.requirements.java.InetAddressVerifier requireThat(InetAddress actual, String name) Verifies the requirements of anInetAddress
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a verifier for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-
validateThat
public static com.github.cowwoc.requirements.java.InetAddressValidator validateThat(InetAddress actual, String name) Validates the requirements of anInetAddress
.- Parameters:
actual
- the actual valuename
- the name of the value- Returns:
- a validator for the value
- Throws:
NullPointerException
- ifname
is nullIllegalArgumentException
- ifname
is blank
-