Example usage for java.lang NullPointerException NullPointerException

List of usage examples for java.lang NullPointerException NullPointerException

Introduction

In this page you can find the example usage for java.lang NullPointerException NullPointerException.

Prototype

public NullPointerException(String s) 

Source Link

Document

Constructs a NullPointerException with the specified detail message.

Usage

From source file:Main.java

public static <T> void fromArrayToCollection(T[] a, Collection<T> c) {
    if (c == null)
        throw new NullPointerException("Collection must be not null");
    for (T e : a) {
        c.add(e);//from w  w  w  .j  a  v  a  2 s  . com
    }
}

From source file:Main.java

public static void checkNull(String message, Object value) {
    if (value == null) {
        throw new NullPointerException(message + " should not be null");
    }/*from   w  w w. java  2s  . co m*/
}

From source file:Main.java

public static <T> T requireNonNull(T o, String message) {
    if (o == null) {
        throw new NullPointerException(message);
    }/* w w w.  j  a v  a  2s  .c o m*/
    return o;
}

From source file:Main.java

public static <T> T checkNotNull(T object, String message) {
    if (object == null)
        throw new NullPointerException(message);
    return object;
}

From source file:Main.java

public static boolean isValidIndex(JComboBox<?> comboBox, int index) {
    if (comboBox == null) {
        throw new NullPointerException("comboBox == null");
    }//from ww w.  j  a v  a2 s . c om
    int itemCount = comboBox.getItemCount();
    return index >= 0 && index < itemCount;
}

From source file:Main.java

public static void checkNullOrEmpty(String message, String value) {
    if (isEmpty(value)) {
        throw new NullPointerException(message + " should not be null or empty");
    }/*from   w w  w  .  j ava  2 s  .  c  o  m*/
}

From source file:Main.java

public static boolean isValidPass(EditText paramEditText) {
    if (paramEditText == null) {
        throw new NullPointerException("EditText can't null");
    }/* ww w .j  av a2s  .com*/
    return isValidPass(paramEditText.getText().toString());
}

From source file:Main.java

public static Context getInstance() {
    if (sContext == null) {
        throw new NullPointerException("the context is null,please init AppContextUtil in Application first.");
    }//w  ww  .j  a  v  a2  s.  co m
    return sContext;
}

From source file:Main.java

public static void checkNull() {
    if (matoContext == null) {
        throw new NullPointerException("context is null");
    }//  www  .  j  ava  2 s.c  om
}

From source file:Main.java

public static Context getInstance() {
    if (mContext == null) {
        throw new NullPointerException("context is null in appcontxtutils,please init");
    }/*from w  w w  .j  a  v a2 s.  c  om*/
    return mContext;

}