From 711baa28cae894f855d9c9e4d11165c974db9259 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Fri, 22 Nov 2024 02:18:58 +0000 Subject: [PATCH] a reformat code --- .../java/org/lambda/query/QueryableTest.java | 10 ++++++---- .../src/main/java/org/lambda/query/Query.java | 17 ++++++++++------- .../main/java/org/lambda/query/Queryable.java | 6 ++++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java b/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java index e622cb28..93215d9a 100644 --- a/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java +++ b/approvaltests-util-tests/src/test/java/org/lambda/query/QueryableTest.java @@ -229,12 +229,14 @@ private static void verifyQueryable(Queryable queryable) Approvals.verifyAll("", queryable.orderBy(i -> i)); } @Test - void testFirstOrThrow() { + void testFirstOrThrow() + { var expected = """ - java.lang.RuntimeException: 4 not found - """; + java.lang.RuntimeException: 4 not found + """; Queryable queryable = Queryable.as(1, 2, 3); assertEquals(3, queryable.first(i -> 2 < i)); - Approvals.verifyException(() -> queryable.firstOrThrow(i -> i == 4, () -> new RuntimeException("4 not found")), new Options().inline(expected)); + Approvals.verifyException(() -> queryable.firstOrThrow(i -> i == 4, () -> new RuntimeException("4 not found")), + new Options().inline(expected)); } } diff --git a/approvaltests-util/src/main/java/org/lambda/query/Query.java b/approvaltests-util/src/main/java/org/lambda/query/Query.java index 3df6d82d..cdb601ae 100644 --- a/approvaltests-util/src/main/java/org/lambda/query/Query.java +++ b/approvaltests-util/src/main/java/org/lambda/query/Query.java @@ -57,16 +57,19 @@ public static In first(Iterable list, Function1 filter) } return null; } - public static In firstOrThrow(In[] list, Function1 filter, Function0 exception) throws E { + public static In firstOrThrow(In[] list, Function1 filter, + Function0 exception) throws E + { return firstOrThrow(Arrays.asList(list), filter, exception); } - public static In firstOrThrow(Iterable list, Function1 filter, Function0 exception) throws E { - In i = first(list, filter); - if (i == null) { - throw exception.call(); + public static In firstOrThrow(Iterable list, Function1 filter, + Function0 exception) throws E + { + In i = first(list, filter); + if (i == null) + { throw exception.call(); } + return i; } - return i; -} public static Queryable where(In[] list, Function1 filter) { Queryable out = new Queryable(); diff --git a/approvaltests-util/src/main/java/org/lambda/query/Queryable.java b/approvaltests-util/src/main/java/org/lambda/query/Queryable.java index b3531051..e906edc0 100644 --- a/approvaltests-util/src/main/java/org/lambda/query/Queryable.java +++ b/approvaltests-util/src/main/java/org/lambda/query/Queryable.java @@ -71,14 +71,16 @@ public In first(Function1 filter) { return Query.first(this, filter); } - public In firstOrThrow(Function1 filter, Function0 exception) throws E { + public In firstOrThrow(Function1 filter, Function0 exception) throws E + { return Query.firstOrThrow(this, filter, exception); } public In firstOrDefault(In defaultValue) { return this.isEmpty() ? defaultValue : this.get(0); } - public Action0 firstOrThrow(In i, Object o) { + public Action0 firstOrThrow(In i, Object o) + { return null; } public boolean all(Function1 filter)