Package org.jmxtrans.embedded.util
Class Preconditions
java.lang.Object
org.jmxtrans.embedded.util.Preconditions
public class Preconditions extends Object
Inspired by
com.google.common.base.Preconditions- Author:
- Cyrille Le Clerc
-
Method Summary
Modifier and Type Method Description static StringcheckNotEmpty(String reference)Check the nullity and emptiness of the givenreference.static StringcheckNotEmpty(String reference, String message)Check the nullity and emptiness of the givenreference.static <T> TcheckNotNull(T reference)Check the nullity of the givenreference.static <T> TcheckNotNull(T reference, String message)Check the nullity of the givenreference.static voidcheckState(boolean state, String message)Check the givenstate.
-
Method Details
-
checkNotNull
Check the nullity of the givenreference.- Parameters:
reference- reference to check- Returns:
- the given
reference - Throws:
NullPointerException- if the givenreferenceisnull
-
checkNotNull
public static <T> T checkNotNull(T reference, @Nullable String message) throws NullPointerExceptionCheck the nullity of the givenreference.- Parameters:
reference- reference to checkmessage- exception message, can benull- Returns:
- the given
reference - Throws:
NullPointerException- if the givenreferenceisnull
-
checkNotEmpty
Check the nullity and emptiness of the givenreference.- Parameters:
reference- reference to check- Returns:
- the given
reference - Throws:
IllegalArgumentException- if the givenreferenceisnull
-
checkNotEmpty
public static String checkNotEmpty(String reference, @Nullable String message) throws IllegalArgumentExceptionCheck the nullity and emptiness of the givenreference.- Parameters:
reference- reference to checkmessage- exception message, can benull- Returns:
- the given
reference - Throws:
IllegalArgumentException- if the givenreferenceisnull
-
checkState
public static void checkState(boolean state, @Nullable String message) throws IllegalStateExceptionCheck the givenstate.- Parameters:
state- the state top checkmessage- exception message, can benull- Throws:
IllegalStateException- if the givenstateisfalse
-