From 141b7dd6640199c48f635e4640ea7566b91280fc Mon Sep 17 00:00:00 2001 From: Toshihiro Suzuki Date: Tue, 12 Dec 2023 11:38:26 +0900 Subject: [PATCH] Add ThrowableConsumer --- .../java/com/scalar/db/common/TableMetadataManager.java | 2 +- .../src/main/java/com/scalar/db/util/ThrowableConsumer.java | 6 ++++++ .../src/main/java/com/scalar/db/util/ThrowableFunction.java | 2 +- .../java/com/scalar/db/common/TableMetadataManagerTest.java | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 core/src/main/java/com/scalar/db/util/ThrowableConsumer.java diff --git a/core/src/main/java/com/scalar/db/common/TableMetadataManager.java b/core/src/main/java/com/scalar/db/common/TableMetadataManager.java index 062df0b076..5fbadf306d 100644 --- a/core/src/main/java/com/scalar/db/common/TableMetadataManager.java +++ b/core/src/main/java/com/scalar/db/common/TableMetadataManager.java @@ -27,7 +27,7 @@ public TableMetadataManager(Admin admin, long cacheExpirationTimeSecs) { } public TableMetadataManager( - ThrowableFunction, TableKey, Exception> getTableMetadataFunc, + ThrowableFunction, Exception> getTableMetadataFunc, long cacheExpirationTimeSecs) { CacheBuilder builder = CacheBuilder.newBuilder(); if (cacheExpirationTimeSecs >= 0) { diff --git a/core/src/main/java/com/scalar/db/util/ThrowableConsumer.java b/core/src/main/java/com/scalar/db/util/ThrowableConsumer.java new file mode 100644 index 0000000000..e6017221c8 --- /dev/null +++ b/core/src/main/java/com/scalar/db/util/ThrowableConsumer.java @@ -0,0 +1,6 @@ +package com.scalar.db.util; + +@FunctionalInterface +public interface ThrowableConsumer { + void accept(A arg) throws T; +} diff --git a/core/src/main/java/com/scalar/db/util/ThrowableFunction.java b/core/src/main/java/com/scalar/db/util/ThrowableFunction.java index eb839d7673..f846532944 100644 --- a/core/src/main/java/com/scalar/db/util/ThrowableFunction.java +++ b/core/src/main/java/com/scalar/db/util/ThrowableFunction.java @@ -1,6 +1,6 @@ package com.scalar.db.util; @FunctionalInterface -public interface ThrowableFunction { +public interface ThrowableFunction { R apply(A arg) throws T; } diff --git a/core/src/test/java/com/scalar/db/common/TableMetadataManagerTest.java b/core/src/test/java/com/scalar/db/common/TableMetadataManagerTest.java index 03bedef24b..9c6d01f0d6 100644 --- a/core/src/test/java/com/scalar/db/common/TableMetadataManagerTest.java +++ b/core/src/test/java/com/scalar/db/common/TableMetadataManagerTest.java @@ -26,7 +26,7 @@ public class TableMetadataManagerTest { @Mock private DistributedStorageAdmin admin; @Mock - private ThrowableFunction, TableMetadataManager.TableKey, Exception> + private ThrowableFunction, Exception> getTableMetadataFunc; @BeforeEach