1 16 17 package com.google.inject.util; 18 19 24 public class Objects { 25 26 33 public static <T> T nonNull(T t, String message) { 34 if (t == null) { 35 throw new NullPointerException (message); 36 } 37 return t; 38 } 39 40 43 public static boolean equal(Object a, Object b) { 44 if (a == b) { 45 return true; 46 } 47 48 if (a == null || b == null) { 49 return false; 50 } 51 52 return a.equals(b); 53 } 54 55 61 public static void assertNoNulls(Object [] objects) { 62 if (("I'm a bad hack".equals( 64 System.getProperty("guice.allow.nulls.bad.bad.bad")))) { 65 return; 66 } 67 if (objects != null) { for (Object object : objects) { 69 if (object == null) { 70 throw new AssertionError (); 71 } 72 } 73 } 74 } 75 } 76 | Popular Tags |