Checks that the specified object reference is not null
and
throws a customized NullPointerException
if it is.
Unlike the method requireNonNull(Object, String)
,
this method allows creation of the message to be deferred until
after the null check is made. While this may confer a
performance advantage in the non-null case, when deciding to
call this method care should be taken that the costs of
creating the message supplier are less than the cost of just
creating the string message directly.
obj | the object reference to check for nullity | |
messageSupplier | supplier of the detail message to be
used in the event that a NullPointerException is thrown | |
<T> | the type of the reference |
obj
if not null
NullPointerException | if obj is null |
Diagram: Object