Preconditions { @SuppressWarnings("ConstantConditions") @NonNull public static <T> T checkNotNull(@NonNull final T object) { if (object == null) { throw new NullPointerException(); } return object; } private  Preconditions(); static void checkState(final boolean expression, @NonNull final String errorMessage); static void checkArgument(final boolean expression, @NonNull final String errorMessage); @SuppressWarnings("ConstantConditions") @NonNull static T checkNotNull(@NonNull final T object);  }
@Test(expected = NullPointerException.class) public void shouldThrowNullPointerExceptionForCheckNotNullWithNull() { checkNotNull(null); }
@Test public void shouldNotThrowExceptionForCheckNotNullWithValidObject() { checkNotNull(new Object()); }