Package org.jmxtrans.agent.util
Class Preconditions2
java.lang.Object
org.jmxtrans.agent.util.Preconditions2
public class Preconditions2 extends Object
Inspired by
com.google.common.base.Preconditions- Author:
- Cyrille Le Clerc
-
Method Summary
Modifier and Type Method Description static voidcheckArgument(boolean expression)static voidcheckArgument(boolean expression, String msg)static voidcheckArgument(boolean expression, String msgFormat, Object... msgArgs)static StringcheckNotEmpty(String str)static <T> TcheckNotNull(T t)static <T> TcheckNotNull(T reference, String message)Check the nullity of the givenreference.
-
Method Details
-
checkNotNull
public static <T> T checkNotNull(T t) -
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
-
checkArgument
- Throws:
IllegalArgumentException
-
checkArgument
public static void checkArgument(boolean expression, @Nullable String msg) throws IllegalArgumentException- Throws:
IllegalArgumentException
-
checkArgument
public static void checkArgument(boolean expression, @Nullable String msgFormat, Object... msgArgs) throws IllegalArgumentException- Parameters:
expression-msgFormat-msgArgs-- Throws:
IllegalArgumentException- See Also:
String.format(String, Object...)
-