public final class Assertions extends Object
All verifier implementations must be immutable and final.
| Constructor and Description |
|---|
Assertions(boolean enabled)
Creates a new assertion.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
isEnabled() |
BigDecimalRequirements |
requireThat(BigDecimal parameter,
String name)
Same as
Requirements.requireThat(BigDecimal, String) but does nothing if assertions are
disabled. |
<T> ClassRequirements<T> |
requireThat(Class<T> parameter,
String name)
Same as
Requirements.requireThat(Class, String) but does nothing if assertions are
disabled. |
<E> CollectionRequirements<E> |
requireThat(Collection<E> parameter,
String name)
Same as
Requirements.requireThat(Collection, String) but does nothing if assertions are
disabled. |
<K,V> MapRequirements<K,V> |
requireThat(Map<K,V> parameter,
String name)
Same as
Requirements.requireThat(Map, String) but does nothing if assertions are
disabled. |
ObjectRequirements<Object> |
requireThat(Object parameter,
String name)
Same as
Requirements.requireThat(Object, String) but does nothing if assertions are
disabled. |
OptionalRequirements |
requireThat(Optional<?> parameter,
String name)
Same as
Requirements.requireThat(Optional, String) but does nothing if assertions are
disabled. |
PathRequirements |
requireThat(Path parameter,
String name)
Same as
Requirements.requireThat(Path, String) but does nothing if assertions are
disabled. |
StringRequirements |
requireThat(String parameter,
String name)
Same as
Requirements.requireThat(String, String) but does nothing if assertions are
disabled. |
<T extends Comparable<? super T>> |
requireThat(T parameter,
String name)
Same as
Requirements.requireThat(Comparable, String) but does nothing if assertions are
disabled. |
<T extends Number & Comparable<? super T>> |
requireThat(T parameter,
String name)
Same as
Requirements.requireThat(Number, String) but does nothing if assertions are
disabled. |
UriRequirements |
requireThat(URI parameter,
String name)
Same as
Requirements.requireThat(URI, String) but does nothing if assertions are
disabled. |
public Assertions(boolean enabled)
To look up whether assertions are enabled for a particular class, invoke:
boolean assertionsEnabled = false;
assert (assertionsEnabled = true);
from within the class in question.
enabled - true if assertions are enabled for the class whose requirements are being
verifiedpublic boolean isEnabled()
public ObjectRequirements<Object> requireThat(Object parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Object, String) but does nothing if assertions are
disabled.
parameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic <E> CollectionRequirements<E> requireThat(Collection<E> parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Collection, String) but does nothing if assertions are
disabled.
E - the type of element in the collectionparameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic <T extends Comparable<? super T>> ComparableRequirements<T> requireThat(T parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Comparable, String) but does nothing if assertions are
disabled.
T - the type of the numberparameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic <T extends Number & Comparable<? super T>> NumberRequirements<T> requireThat(T parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Number, String) but does nothing if assertions are
disabled.T - the type of the numberparameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic BigDecimalRequirements requireThat(BigDecimal parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(BigDecimal, String) but does nothing if assertions are
disabled.
parameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic <K,V> MapRequirements<K,V> requireThat(Map<K,V> parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Map, String) but does nothing if assertions are
disabled.
K - the type of key in the mapV - the type of value in the mapparameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic PathRequirements requireThat(Path parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Path, String) but does nothing if assertions are
disabled.
parameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic StringRequirements requireThat(String parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(String, String) but does nothing if assertions are
disabled.
parameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic UriRequirements requireThat(URI parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(URI, String) but does nothing if assertions are
disabled.
parameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic <T> ClassRequirements<T> requireThat(Class<T> parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Class, String) but does nothing if assertions are
disabled.
T - the type of classparameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptypublic OptionalRequirements requireThat(Optional<?> parameter, String name) throws NullPointerException, IllegalArgumentException
Requirements.requireThat(Optional, String) but does nothing if assertions are
disabled.
parameter - the value of the parametername - the name of the parameterNullPointerException - if name is nullIllegalArgumentException - if name is emptyCopyright © 2016. All rights reserved.