Class NullChecker


  • public class NullChecker
    extends java.lang.Object
    Utility methods for checking whether values are null.
    • Constructor Summary

      Constructors 
      Constructor Description
      NullChecker()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T checkNotNull​(T obj, java.lang.String name)
      Returns the given object unchanged, throwing a NullPointerException if it is null.
      • Methods inherited from class java.lang.Object

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

      • NullChecker

        public NullChecker()
    • Method Detail

      • checkNotNull

        @Nonnull
        public static <T> T checkNotNull​(@Nonnull
                                         T obj,
                                         @Nonnull
                                         java.lang.String name)
                                  throws java.lang.NullPointerException
        Returns the given object unchanged, throwing a NullPointerException if it is null.
        Parameters:
        obj - The object which should be non-null
        name - The variable name to use in the generated NullPointerException
        Returns:
        The given object, unchanged
        Throws:
        java.lang.NullPointerException