org.assertj.core.util
Class Preconditions

java.lang.Object
  extended by org.assertj.core.util.Preconditions

public final class Preconditions
extends Object

Verifies correct argument values and state. Borrowed from Guava.

Author:
alruiz@google.com (Alex Ruiz)

Field Summary
static String ARGUMENT_EMPTY
           
 
Method Summary
static
<T> T
checkNotNull(T reference)
          Verifies that the given object reference is not null.
static
<T> T
checkNotNull(T reference, String message)
          Verifies that the given object reference is not null.
static String checkNotNullOrEmpty(String s)
          Verifies that the given String is not null or empty.
static String checkNotNullOrEmpty(String s, String message)
          Verifies that the given String is not null or empty.
static
<T> T[]
checkNotNullOrEmpty(T[] array)
          Verifies that the given array is not null or empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARGUMENT_EMPTY

public static final String ARGUMENT_EMPTY
See Also:
Constant Field Values
Method Detail

checkNotNullOrEmpty

public static String checkNotNullOrEmpty(String s)
Verifies that the given String is not null or empty.

Parameters:
s - the given String.
Returns:
the validated String.
Throws:
NullPointerException - if the given String is null.
IllegalArgumentException - if the given String is empty.

checkNotNullOrEmpty

public static String checkNotNullOrEmpty(String s,
                                         String message)
Verifies that the given String is not null or empty.

Parameters:
s - the given String.
message - error message in case of empty String.
Returns:
the validated String.
Throws:
NullPointerException - if the given String is null.
IllegalArgumentException - if the given String is empty.

checkNotNullOrEmpty

public static <T> T[] checkNotNullOrEmpty(T[] array)
Verifies that the given array is not null or empty.

Parameters:
array - the given array.
Returns:
the validated array.
Throws:
NullPointerException - if the given array is null.
IllegalArgumentException - if the given array is empty.

checkNotNull

public static <T> T checkNotNull(T reference)
Verifies that the given object reference is not null.

Parameters:
reference - the given object reference.
Returns:
the non-null reference that was validated.
Throws:
NullPointerException - if the given object reference is null.

checkNotNull

public static <T> T checkNotNull(T reference,
                                 String message)
Verifies that the given object reference is not null.

Parameters:
reference - the given object reference.
message - error message in case of null reference.
Returns:
the non-null reference that was validated.
Throws:
NullPointerException - if the given object reference is null.


Copyright © 2013–2015 AssertJ. All rights reserved.