Class NullCheckingUtil


  • public class NullCheckingUtil
    extends java.lang.Object
    Author:
    Elias Ricken de Medeiros
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void badStateIfNull​(java.lang.Object valueToCheck, java.lang.String msg)
      This method throw an IllegalStateException if the given parameter is null
      static void badStateIfTrue​(boolean valueToCheck, java.lang.String msg)
      This method throw an IllegalStateException if the given parameter is true
      static void checkArgsNotNull​(java.lang.Object... params)
      Check that the given parameters are not null.
      static NullCheckingUtil.NullCheckResult findNull​(java.lang.Object... params)
      Find null parameters in the given list.
      static java.lang.StackTraceElement getCaller​(int offset)
      Return the StackTraceElement at the given offset from this method invocation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • NullCheckingUtil

        public NullCheckingUtil()
    • Method Detail

      • checkArgsNotNull

        public static void checkArgsNotNull​(java.lang.Object... params)
        Check that the given parameters are not null. This method should only be used to check that some parameters given to a given method are not null. The exception message tries its best to produce a helpful message by scanning the stack trace.
        Parameters:
        params - the parameters to check
        Throws:
        java.lang.IllegalArgumentException - if at least one of the parameters is null
      • getCaller

        public static java.lang.StackTraceElement getCaller​(int offset)
        Return the StackTraceElement at the given offset from this method invocation.
        Parameters:
        offset -
        Returns:
        a StackTraceElement
      • badStateIfNull

        public static void badStateIfNull​(java.lang.Object valueToCheck,
                                          java.lang.String msg)
        This method throw an IllegalStateException if the given parameter is null
        Parameters:
        valueToCheck - the value to check
        msg - the message for the thrown exception
        See Also:
        IllegalStateException
      • badStateIfTrue

        public static void badStateIfTrue​(boolean valueToCheck,
                                          java.lang.String msg)
        This method throw an IllegalStateException if the given parameter is true
        Parameters:
        valueToCheck - the value to check
        msg - the message for the thrown exception
        See Also:
        IllegalStateException