Here you can find the source of assertNonNull(final T object, final String paramName)
Parameter | Description |
---|---|
object | value to be null-checked |
paramName | message for the potential NullPointerException |
Parameter | Description |
---|---|
NullPointerException | if object is null |
public static <T> T assertNonNull(final T object, final String paramName) throws NullPointerException
//package com.java2s; /*/*from www . j a v a2 s. c o m*/ * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except * in compliance with the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 { /** * Throws {@link NullPointerException} with message {@code paramName} if {@code object} is null. * * @param object * value to be null-checked * @param paramName * message for the potential {@link NullPointerException} * @return {@code object} * @throws NullPointerException * if {@code object} is null */ public static <T> T assertNonNull(final T object, final String paramName) throws NullPointerException { if (object == null) { throw new NullPointerException(paramName + " must not be null"); } return object; } }