Skip to content

Commit 4aa3a52

Browse files
committed
- B parity of Lists an Arrays
1 parent 948311f commit 4aa3a52

File tree

1 file changed

+8
-5
lines changed
  • approvaltests-util/src/main/java/org/lambda/query

1 file changed

+8
-5
lines changed

approvaltests-util/src/main/java/org/lambda/query/Query.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ public static <In> In first(Iterable<In> list, Function1<In, Boolean> filter)
5757
}
5858
return null;
5959
}
60+
public static <In, E extends Throwable> In firstOrThrow(In[] list, Function1<In, Boolean> filter, Function0<E> exception) throws E {
61+
return firstOrThrow(Arrays.asList(list), filter, exception);
62+
}
6063
public static <In, E extends Throwable> In firstOrThrow(Iterable<In> list, Function1<In, Boolean> filter, Function0<E> exception) throws E {
61-
In i = first(list, filter);
62-
if (i == null) {
63-
throw exception.call();
64-
}
65-
return i;
64+
In i = first(list, filter);
65+
if (i == null) {
66+
throw exception.call();
6667
}
68+
return i;
69+
}
6770
public static <In> Queryable<In> where(In[] list, Function1<In, Boolean> filter)
6871
{
6972
Queryable<In> out = new Queryable<In>();

0 commit comments

Comments
 (0)