Package org.jmxtrans.agent.util
Class Preconditions2
java.lang.Object
org.jmxtrans.agent.util.Preconditions2
public class Preconditions2
extends java.lang.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, java.lang.String msg)static voidcheckArgument(boolean expression, java.lang.String msgFormat, java.lang.Object... msgArgs)static java.lang.StringcheckNotEmpty(java.lang.String str)static <T> TcheckNotNull(T t)static <T> TcheckNotNull(T reference, java.lang.String message)Check the nullity of the givenreference.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
checkNotNull
public static <T> T checkNotNull(T t) -
checkNotNull
public static <T> T checkNotNull(T reference, @Nullable java.lang.String message) throws java.lang.NullPointerExceptionCheck the nullity of the givenreference.- Parameters:
reference- reference to checkmessage- exception message, can benull- Returns:
- the given
reference - Throws:
java.lang.NullPointerException- if the givenreferenceisnull
-
checkNotEmpty
public static java.lang.String checkNotEmpty(java.lang.String str) -
checkArgument
public static void checkArgument(boolean expression) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
checkArgument
public static void checkArgument(boolean expression, @Nullable java.lang.String msg) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
checkArgument
public static void checkArgument(boolean expression, @Nullable java.lang.String msgFormat, java.lang.Object... msgArgs) throws java.lang.IllegalArgumentException- Parameters:
expression-msgFormat-msgArgs-- Throws:
java.lang.IllegalArgumentException- See Also:
String.format(String, Object...)
-