From f936c65cd4d288d21ff2f71d1afac63e67de9270 Mon Sep 17 00:00:00 2001 From: Carsten Otto Date: Tue, 3 May 2022 17:23:18 +0200 Subject: [PATCH] refactor to use switch statement --- .../service/LiquidityInformationUpdater.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/de/cotto/lndmanagej/service/LiquidityInformationUpdater.java b/backend/src/main/java/de/cotto/lndmanagej/service/LiquidityInformationUpdater.java index d52415c1..c7cd6282 100644 --- a/backend/src/main/java/de/cotto/lndmanagej/service/LiquidityInformationUpdater.java +++ b/backend/src/main/java/de/cotto/lndmanagej/service/LiquidityInformationUpdater.java @@ -55,14 +55,14 @@ public class LiquidityInformationUpdater implements PaymentListener { @Override public void failure(List paymentAttemptHops, FailureCode failureCode, int failureSourceIndex) { - if (TEMPORARY_CHANNEL_FAILURE.equals(failureCode)) { - markAvailableAndUnavailable(paymentAttemptHops, failureSourceIndex, PaymentAttemptHop::amount); - } else if (UNKNOWN_NEXT_PEER.equals(failureCode) || CHANNEL_DISABLED.equals(failureCode)) { - markAvailableAndUnavailable(paymentAttemptHops, failureSourceIndex, hop -> Coins.ofSatoshis(1)); - } else if (MPP_TIMEOUT.equals(failureCode) || INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS.equals(failureCode)) { - markAllAvailable(paymentAttemptHops, failureSourceIndex); - } else { - logger.warn("Unknown failure code {}", failureCode); + switch (failureCode) { + case TEMPORARY_CHANNEL_FAILURE -> + markAvailableAndUnavailable(paymentAttemptHops, failureSourceIndex, PaymentAttemptHop::amount); + case UNKNOWN_NEXT_PEER, CHANNEL_DISABLED -> + markAvailableAndUnavailable(paymentAttemptHops, failureSourceIndex, hop -> Coins.ofSatoshis(1)); + case MPP_TIMEOUT, INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS -> + markAllAvailable(paymentAttemptHops, failureSourceIndex); + default -> logger.warn("Unknown failure code {}", failureCode); } }