List of usage examples for java.lang NullPointerException NullPointerException
public NullPointerException(String s)
From source file:Main.java
public static void frag2Act(Fragment fragment, Class<?> cls) { if (fragment == null || cls == null) { throw new NullPointerException("fragment or cls null"); }// w w w. ja va 2 s. co m Intent intent = new Intent(fragment.getActivity(), cls); fragment.startActivity(intent); }
From source file:Main.java
public static boolean containsStringIgnoreCase(Collection<? extends String> strings, String string) { if (strings == null) { throw new NullPointerException("strings == null"); }//from w w w . j a v a 2s. c om if (string == null) { throw new NullPointerException("string == null"); } for (String s : strings) { if (string.equalsIgnoreCase(s)) { return true; } } return false; }
From source file:Main.java
public static <K, V> Map<K, V> copyNullSafeMutableHashMap(Map<? extends K, ? extends V> map) { if (map == null) throw new NullPointerException("map"); Map<K, V> result = new HashMap<K, V>(map); for (Map.Entry<K, V> entry : result.entrySet()) { if (entry.getKey() == null) throw new NullPointerException("entry.getKey()"); if (entry.getValue() == null) throw new NullPointerException("entry.getValue()"); }// w ww.j a va 2s . c o m return result; }
From source file:Main.java
public static Frame findParentFrame(Component component) { if (component == null) { throw new NullPointerException("component == null"); }//w w w . j av a 2 s .c o m Container parent = component.getParent(); while (parent != null) { if ((parent instanceof Frame)) { return (Frame) parent; } parent = parent.getParent(); } return null; }
From source file:Main.java
public static boolean isSame(EditText paramEditText1, EditText paramEditText2) { if ((paramEditText1 == null) || (paramEditText2 == null)) { throw new NullPointerException("EditText can't null"); }/*from ww w . ja va 2 s.c om*/ return isSame(paramEditText1.getText().toString(), paramEditText2.getText().toString()); }
From source file:Main.java
public static void parentWindowToFront(Component component) { if (component == null) { throw new NullPointerException("component == null"); }//ww w . j a v a 2s .co m Container parent = component.getParent(); while (parent != null) { if ((parent instanceof Window)) { Window parentWindow = (Window) parent; parentWindow.toFront(); return; } parent = parent.getParent(); } }
From source file:Main.java
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage) { if (reference == null) { throw new NullPointerException(String.valueOf(errorMessage)); }/*from w ww . ja va 2s . c o m*/ return reference; }
From source file:Main.java
private static void ckeckNullPackageName(String packageName) { if (packageName == null || packageName.trim().length() == 0) throw new NullPointerException(ERROR_MESSAGE); }
From source file:Main.java
public static <T> T requireNonNull(T object, String error) { if (object == null) throw new NullPointerException(error); return object; }
From source file:Main.java
private static String getStringFromPrefsOrThow(SharedPreferences prefs, String key) { String val = prefs.getString(key, null); if (val == null) { throw new NullPointerException("Trying to retrieve pin value before it's been set"); }//w w w . j ava2 s . c o m return val; }