Skip to content

Commit

Permalink
Backport to branch(3) : Add ThrowableConsumer (#1382)
Browse files Browse the repository at this point in the history
Co-authored-by: Toshihiro Suzuki <[email protected]>
  • Loading branch information
feeblefakie and brfrn169 authored Dec 14, 2023
1 parent 0d8830f commit 9194e7a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public TableMetadataManager(Admin admin, long cacheExpirationTimeSecs) {
}

public TableMetadataManager(
ThrowableFunction<Optional<TableMetadata>, TableKey, Exception> getTableMetadataFunc,
ThrowableFunction<TableKey, Optional<TableMetadata>, Exception> getTableMetadataFunc,
long cacheExpirationTimeSecs) {
CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder();
if (cacheExpirationTimeSecs >= 0) {
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/java/com/scalar/db/util/ThrowableConsumer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.scalar.db.util;

@FunctionalInterface
public interface ThrowableConsumer<A, T extends Throwable> {
void accept(A arg) throws T;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.scalar.db.util;

@FunctionalInterface
public interface ThrowableFunction<R, A, T extends Throwable> {
public interface ThrowableFunction<A, R, T extends Throwable> {
R apply(A arg) throws T;
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TableMetadataManagerTest {
@Mock private DistributedStorageAdmin admin;

@Mock
private ThrowableFunction<Optional<TableMetadata>, TableMetadataManager.TableKey, Exception>
private ThrowableFunction<TableMetadataManager.TableKey, Optional<TableMetadata>, Exception>
getTableMetadataFunc;

@BeforeEach
Expand Down

0 comments on commit 9194e7a

Please sign in to comment.