Java Assert Not Null assertNotNull(T obj)

Here you can find the source of assertNotNull(T obj)

Description

assert Not Null

License

Open Source License

Declaration

public static <T> T assertNotNull(T obj) 

Method Source Code

//package com.java2s;
// The MIT License (MIT)

public class Main {
    public static <T> T assertNotNull(T obj) {
        if (obj == null) {
            throw new NullPointerException();
        }//from  w  w  w.  j a v a  2 s  .  c o m
        return obj;
    }

    public static <T> T assertNotNull(T obj, String errorMessage) {
        if (obj == null) {
            throw new NullPointerException(errorMessage);
        }
        return obj;
    }
}

Related

  1. assertNotNull(String message, Object val)
  2. assertNotNull(String variableName, Object value)
  3. assertNotNull(StringBuilder buffer)
  4. assertNotNull(T exception, Object... objects)
  5. assertNotNull(T o)
  6. assertNotNull(T object, String fieldName)
  7. assertNotNull(T value, String message)
  8. assertNotNullArg(Object value, String argName)
  9. assertNotNullArgument(Object obj, String argName)