CheckUtil.java 582 B

123456789101112131415161718192021
  1. package cn.nosum.support.utils;
  2. import static java.lang.String.format;
  3. /**
  4. * Checking Tool.
  5. *
  6. * @author Young
  7. */
  8. public class CheckUtil {
  9. public static <T> T checkNotNull(T reference,
  10. String errorMessageTemplate,
  11. Object... errorMessageArgs) {
  12. if (reference == null) {
  13. // If either of these parameters is null, the right thing happens anyway
  14. throw new NullPointerException(format(errorMessageTemplate, errorMessageArgs));
  15. }
  16. return reference;
  17. }
  18. }