Class Objects


  • public class Objects
    extends Object
    Backport of some utility methods from Java 1.7+
    • Method Detail

      • requireNonNull

        public static <T> T requireNonNull​(T object)
        Returns the given object if it is non-null, otherwise throws NullPointerException.
        Parameters:
        object - the object to check for nullity
        Returns:
        the given object
        Throws:
        NullPointerException - if object is null
      • requireNonNull

        public static <T> T requireNonNull​(T object,
                                           String message)
        Returns the given object if it is non-null, otherwise throws NullPointerException with the given message.
        Parameters:
        object - the object to check for nullity
        message - the detail message to use if the object is null
        Returns:
        the given object
        Throws:
        NullPointerException - if object is null