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 void checkArgument​(boolean expression)  
    static void checkArgument​(boolean expression, java.lang.String msg)  
    static void checkArgument​(boolean expression, java.lang.String msgFormat, java.lang.Object... msgArgs)  
    static java.lang.String checkNotEmpty​(java.lang.String str)  
    static <T> T checkNotNull​(T t)  
    static <T> T checkNotNull​(T reference, java.lang.String message)
    Check the nullity of the given reference.

    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.NullPointerException
      Check the nullity of the given reference.
      Parameters:
      reference - reference to check
      message - exception message, can be null
      Returns:
      the given reference
      Throws:
      java.lang.NullPointerException - if the given reference is null
    • 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...)