Java tutorial
//package com.java2s; //License from project: Open Source License import javax.annotation.Nullable; public class Main { public static <T> T checkNotNull(T reference, @Nullable Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); } return reference; } public static <T> T checkNotNull(T reference) { if (reference == null) { throw new NullPointerException(); } return reference; } }