Java tutorial
//package com.java2s; public class Main { public static <T> T requireNonNull(T object) { return requireNonNull(object, "Null reference"); } public static <T> T requireNonNull(T object, String error) { if (object == null) throw new NullPointerException(error); return object; } }