Here you can find the source of assertNotNull(T object, String fieldName)
Parameter | Description |
---|---|
object | Object to assert on |
fieldName | Field name to display in exception message if null |
T | the type of object. |
public static <T> T assertNotNull(T object, String fieldName)
//package com.java2s; //License from project: Amazon Software License public class Main { /**/*from w w w.j a v a 2 s .co m*/ * Asserts that the given object is non-null and returns it. * * @param object Object to assert on * @param fieldName Field name to display in exception message if null * @param <T> the type of object. * @return Object if non null */ public static <T> T assertNotNull(T object, String fieldName) { if (object == null) { throw new IllegalArgumentException(String.format("%s cannot be null", fieldName)); } return object; } }