Java Assert Not Null assertNotNull(Object obj, String msgTemplate, Object... params)

Here you can find the source of assertNotNull(Object obj, String msgTemplate, Object... params)

Description

assert Not Null

License

Apache License

Declaration

public static void assertNotNull(Object obj, String msgTemplate, Object... params) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static void assertNotNull(Object obj, String msgTemplate, Object... params) {

        if (obj == null) {
            throw new NullPointerException(getMsg("Assert fail: should not be null", msgTemplate, params));
        }/*from ww  w .  j  a  va  2 s  . c  o  m*/

    }

    private static String getMsg(String defaultMsg, String msgTemplate, Object[] params) {
        return msgTemplate == null ? defaultMsg : String.format(msgTemplate, params);
    }
}

Related

  1. assertNotNull(Object expression)
  2. assertNotNull(Object o)
  3. assertNotNull(Object obj)
  4. assertNotNull(Object obj)
  5. assertNotNull(Object obj, RuntimeException ex)
  6. assertNotNull(Object obj, String name)
  7. assertNotNull(Object obj, String name)
  8. assertNotNull(Object object)
  9. assertNotNull(Object object, RuntimeException cause)