@Test public void shouldThrowTheSuppliedExceptionIfEmpty() throws Exception { Iterable<String> input = iterable(); try { Checks.returnOrThrowIfEmpty(input, illegalArgumentFactory("Oops")); fail("Expected the supplied exception to be thrown."); } catch (Throwable exception) { assertThat(exception, instanceOf(IllegalArgumentException.class)); assertThat(exception.getMessage(), is("Oops")); } }
public static <S, T extends Iterable<S>> T returnOrThrowIfEmpty( T value, NullaryFunction<? extends RuntimeException> exceptionFactory) { return orThrowIf( value, !value.iterator().hasNext(), exceptionFactory); }
Checks { public static <S, T extends Iterable<S>> T returnOrThrowIfEmpty( T value, NullaryFunction<? extends RuntimeException> exceptionFactory) { return orThrowIf( value, !value.iterator().hasNext(), exceptionFactory); } }
Checks { public static <S, T extends Iterable<S>> T returnOrThrowIfEmpty( T value, NullaryFunction<? extends RuntimeException> exceptionFactory) { return orThrowIf( value, !value.iterator().hasNext(), exceptionFactory); }  }
Checks { public static <S, T extends Iterable<S>> T returnOrThrowIfEmpty( T value, NullaryFunction<? extends RuntimeException> exceptionFactory) { return orThrowIf( value, !value.iterator().hasNext(), exceptionFactory); }  static T returnOrThrowIfNull(T value, NullaryFunction<? extends RuntimeException> exceptionFactory); static T returnOrThrowIfEmpty(
            T value, NullaryFunction<? extends RuntimeException> exceptionFactory); static T returnOrThrowIfContainsNull(T iterable); }
Checks { public static <S, T extends Iterable<S>> T returnOrThrowIfEmpty( T value, NullaryFunction<? extends RuntimeException> exceptionFactory) { return orThrowIf( value, !value.iterator().hasNext(), exceptionFactory); }  static T returnOrThrowIfNull(T value, NullaryFunction<? extends RuntimeException> exceptionFactory); static T returnOrThrowIfEmpty(
            T value, NullaryFunction<? extends RuntimeException> exceptionFactory); static T returnOrThrowIfContainsNull(T iterable);  }