Java Assert Not Null assertNotNull(final String param, final Object value)

Here you can find the source of assertNotNull(final String param, final Object value)

Description

Asserts that a value is not null.

License

Apache License

Parameter

Parameter Description
param A <code>String</code> that represents the name of the parameter, which becomes the exception message text if the <code>value</code> parameter is <code>null</code>.
value An <code>Object</code> object that represents the value of the specified parameter. This is the value being asserted as not <code>null</code>.

Declaration

public static void assertNotNull(final String param, final Object value) 

Method Source Code

//package com.java2s;
/**//from w  ww .  j  a  v  a 2  s.c o  m
 * Copyright Microsoft Corporation
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

public class Main {
    /**
     * Asserts that a value is not <code>null</code>.
     * 
     * @param param
     *            A <code>String</code> that represents the name of the parameter, which becomes the exception message
     *            text if the <code>value</code> parameter is <code>null</code>.
     * @param value
     *            An <code>Object</code> object that represents the value of the specified parameter. This is the value
     *            being asserted as not <code>null</code>.
     */
    public static void assertNotNull(final String param, final Object value) {
        if (value == null) {
            throw new IllegalArgumentException(param);
        }
    }
}

Related

  1. assertNotNull(final Object value, final String name)
  2. assertNotNull(final Object... objects)
  3. assertNotNull(final String message, final Object obj)
  4. assertNotNull(final String message, final Object object)
  5. assertNotNull(final String name, final T object)
  6. assertNotNull(final T object, final String message)
  7. assertNotNull(final T value, final String param)
  8. assertNotNull(Object argumentThatMustNotBeNull, String argumentName)
  9. assertNotNull(Object expression)