com.atlassian.bamboo.performance
Class Assertions

java.lang.Object
  extended by com.atlassian.bamboo.performance.Assertions

public final class Assertions
extends java.lang.Object

Utility class with design by contract checks. Should be preferred to Null.

Since:
v3.13

Method Summary
static
<C extends java.lang.Iterable<java.lang.String>>
C
containsNoBlanks(java.lang.String name, C stringsNotBlank)
          Throw and IllegalArgumentException if the passed collection is null or contains any blank Strings.
static
<C extends java.lang.Iterable<?>>
C
containsNoNulls(java.lang.String name, C containsNoNulls)
          Throw an IllegalArgumentException if the passed collection is null or contains any null values.
static
<C> C[]
containsNoNulls(java.lang.String name, C[] containsNoNulls)
          Throw an IllegalArgumentException if the passed array is null or contains any null values.
static
<T> T
equals(java.lang.String name, T expected, T got)
           
static void not(java.lang.String name, boolean condition)
          Throw an IllegalArgumentException if the condition is true
static java.lang.String notBlank(java.lang.String name, java.lang.String string)
          Throw an IllegalArgumentException if the string is null or blank (only contains whitespace)
static
<T> T
notNull(java.lang.String name, T notNull)
          Throw an IllegalArgumentException if the string is null
static
<T> T
stateNotNull(java.lang.String name, T notNull)
          State check.
static void stateTrue(java.lang.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

notNull

public static <T> T notNull(java.lang.String name,
                            T notNull)
                 throws java.lang.IllegalArgumentException
Throw an IllegalArgumentException if the string is null

Parameters:
name - added to the exception
notNull - should not be null
Returns:
argument being checked.
Throws:
java.lang.IllegalArgumentException - if null

containsNoNulls

public static <C extends java.lang.Iterable<?>> C containsNoNulls(java.lang.String name,
                                                                  C containsNoNulls)
                                                       throws java.lang.IllegalArgumentException
Throw an IllegalArgumentException if the passed collection is null or contains any null values.

Parameters:
name - name added to the exception.
containsNoNulls - the collection to check.
Returns:
the passed in Iterable.
Throws:
java.lang.IllegalArgumentException - if the passed collection is null or contains any null.

containsNoNulls

public static <C> C[] containsNoNulls(java.lang.String name,
                                      C[] containsNoNulls)
                           throws java.lang.IllegalArgumentException
Throw an IllegalArgumentException if the passed array is null or contains any null values.

Parameters:
name - name added to the exception.
containsNoNulls - the collection to check.
Returns:
the passed in Iterable.
Throws:
java.lang.IllegalArgumentException - if the passed collection is null or contains any null.

notBlank

public static java.lang.String notBlank(java.lang.String name,
                                        java.lang.String string)
                                 throws java.lang.IllegalArgumentException
Throw an IllegalArgumentException if the string is null or blank (only contains whitespace)

Parameters:
name - added to the exception
string - should not be null or blank
Returns:
argument being checked.
Throws:
java.lang.IllegalArgumentException - if null or blank

containsNoBlanks

public static <C extends java.lang.Iterable<java.lang.String>> C containsNoBlanks(java.lang.String name,
                                                                                  C stringsNotBlank)
Throw and IllegalArgumentException if the passed collection is null or contains any blank Strings.

Type Parameters:
C - the type of the collection of strings.
Parameters:
name - name added to the exception
stringsNotBlank - the collection of strings that should not be blank.
Returns:
the passed argument.
Throws:
java.lang.IllegalArgumentException - if the passed collection is null or contains any blank strings.

not

public static void not(java.lang.String name,
                       boolean condition)
                throws java.lang.IllegalArgumentException
Throw an IllegalArgumentException if the condition is true

Parameters:
name - added to the exception
condition - should be false
Throws:
java.lang.IllegalArgumentException - if true

stateTrue

public static void stateTrue(java.lang.String name,
                             boolean condition)
                      throws java.lang.IllegalStateException
State check. Throw an IllegalStateException if the condition is false

Parameters:
name - added to the exception
condition - should be true
Throws:
java.lang.IllegalStateException - if false

stateNotNull

public static <T> T stateNotNull(java.lang.String name,
                                 T notNull)
State check. Throw an IllegalStateException if the supplied argument is null.

Parameters:
name - added to the exception
notNull - should not be null
Returns:
argument being checked.
Throws:
java.lang.IllegalStateException - if false

equals

public static <T> T equals(java.lang.String name,
                           T expected,
                           T got)
                throws java.lang.IllegalArgumentException
Throws:
java.lang.IllegalArgumentException


Copyright © 2011 Atlassian. All Rights Reserved.