|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.util.dbc.Assertions
@PublicApi public final class Assertions
Utility class with design by contract checks. Should be preferred to com.atlassian.jira.util.dbcNull
.
Method Summary | ||
---|---|---|
static
|
containsNoBlanks(String name,
C stringsNotBlank)
Throw and IllegalArgumentException if the passed collection is null or contains any blank Strings. |
|
static
|
containsNoNulls(String name,
C containsNoNulls)
Throw an IllegalArgumentException if the passed collection is null or contains any null values. |
|
static
|
containsNoNulls(String name,
C[] containsNoNulls)
Throw an IllegalArgumentException if the passed array is null or contains any null values. |
|
static
|
equals(String name,
T expected,
T got)
|
|
static void |
is(String name,
boolean condition)
Throw an IllegalArgumentException if the condition is false |
|
static void |
not(String name,
boolean condition)
Throw an IllegalArgumentException if the condition is true |
|
static String |
notBlank(String name,
String string)
Throw an IllegalArgumentException if the string is null or blank (only contains whitespace) |
|
static
|
notEmpty(String name,
T notEmpty)
Throw an IllegalArgumentException if the argument is null or empty |
|
static
|
notNull(String name,
T notNull)
Throw an IllegalArgumentException if the string is null |
|
static
|
notNull(T notNull)
|
|
static void |
stateFalse(String name,
boolean condition)
State check. |
|
static
|
stateNotNull(String name,
T notNull)
State check. |
|
static void |
stateTrue(String name,
boolean condition)
State check. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static <T> T notNull(String name, T notNull) throws IllegalArgumentException
name
- added to the exceptionnotNull
- should not be null
IllegalArgumentException
- if nullpublic static <T> T notNull(T notNull) throws IllegalArgumentException
IllegalArgumentException
public static <T extends Collection> T notEmpty(String name, T notEmpty) throws IllegalArgumentException
name
- added to the exceptionnotEmpty
- should not be null or empty
IllegalArgumentException
- if null or emptypublic static <C extends Iterable<?>> C containsNoNulls(String name, C containsNoNulls) throws IllegalArgumentException
name
- name added to the exception.containsNoNulls
- the collection to check.
IllegalArgumentException
- if the passed collection is null or contains any null.public static <C> C[] containsNoNulls(String name, C[] containsNoNulls) throws IllegalArgumentException
name
- name added to the exception.containsNoNulls
- the collection to check.
IllegalArgumentException
- if the passed collection is null or contains any null.public static String notBlank(String name, String string) throws IllegalArgumentException
name
- added to the exceptionstring
- should not be null or blank
IllegalArgumentException
- if null or blankpublic static <C extends Iterable<String>> C containsNoBlanks(String name, C stringsNotBlank)
C
- the type of the collection of strings.name
- name added to the exceptionstringsNotBlank
- the collection of strings that should not be blank.
IllegalArgumentException
- if the passed collection is null or contains any blank strings.public static void not(String name, boolean condition) throws IllegalArgumentException
name
- added to the exceptioncondition
- should be false
IllegalArgumentException
- if truepublic static void is(String name, boolean condition) throws IllegalArgumentException
name
- added to the exceptioncondition
- should be false
IllegalArgumentException
- if truepublic static void stateTrue(String name, boolean condition) throws IllegalStateException
name
- added to the exceptioncondition
- should be true
IllegalStateException
- if falsepublic static void stateFalse(String name, boolean condition) throws IllegalStateException
name
- added to the exceptioncondition
- should be true
IllegalStateException
- if falsepublic static <T> T stateNotNull(String name, T notNull)
name
- added to the exceptionnotNull
- should not be null
IllegalStateException
- if falsepublic static <T> T equals(String name, T expected, T got) throws IllegalArgumentException
IllegalArgumentException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |