Skip to content

Commit 711baa2

Browse files
committed
a reformat code
1 parent 4aa3a52 commit 711baa2

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,14 @@ private static void verifyQueryable(Queryable<Integer> queryable)
229229
Approvals.verifyAll("", queryable.orderBy(i -> i));
230230
}
231231
@Test
232-
void testFirstOrThrow() {
232+
void testFirstOrThrow()
233+
{
233234
var expected = """
234-
java.lang.RuntimeException: 4 not found
235-
""";
235+
java.lang.RuntimeException: 4 not found
236+
""";
236237
Queryable<Integer> queryable = Queryable.as(1, 2, 3);
237238
assertEquals(3, queryable.first(i -> 2 < i));
238-
Approvals.verifyException(() -> queryable.firstOrThrow(i -> i == 4, () -> new RuntimeException("4 not found")), new Options().inline(expected));
239+
Approvals.verifyException(() -> queryable.firstOrThrow(i -> i == 4, () -> new RuntimeException("4 not found")),
240+
new Options().inline(expected));
239241
}
240242
}

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,19 @@ 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 {
60+
public static <In, E extends Throwable> In firstOrThrow(In[] list, Function1<In, Boolean> filter,
61+
Function0<E> exception) throws E
62+
{
6163
return firstOrThrow(Arrays.asList(list), filter, exception);
6264
}
63-
public static <In, E extends Throwable> In firstOrThrow(Iterable<In> list, Function1<In, Boolean> filter, Function0<E> exception) throws E {
64-
In i = first(list, filter);
65-
if (i == null) {
66-
throw exception.call();
65+
public static <In, E extends Throwable> In firstOrThrow(Iterable<In> list, Function1<In, Boolean> filter,
66+
Function0<E> exception) throws E
67+
{
68+
In i = first(list, filter);
69+
if (i == null)
70+
{ throw exception.call(); }
71+
return i;
6772
}
68-
return i;
69-
}
7073
public static <In> Queryable<In> where(In[] list, Function1<In, Boolean> filter)
7174
{
7275
Queryable<In> out = new Queryable<In>();

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,16 @@ public In first(Function1<In, Boolean> filter)
7171
{
7272
return Query.first(this, filter);
7373
}
74-
public <E extends Throwable> In firstOrThrow(Function1<In, Boolean> filter, Function0<E> exception) throws E {
74+
public <E extends Throwable> In firstOrThrow(Function1<In, Boolean> filter, Function0<E> exception) throws E
75+
{
7576
return Query.firstOrThrow(this, filter, exception);
7677
}
7778
public In firstOrDefault(In defaultValue)
7879
{
7980
return this.isEmpty() ? defaultValue : this.get(0);
8081
}
81-
public Action0 firstOrThrow(In i, Object o) {
82+
public Action0 firstOrThrow(In i, Object o)
83+
{
8284
return null;
8385
}
8486
public boolean all(Function1<In, Boolean> filter)

0 commit comments

Comments
 (0)