From 39d799e58fbc29f565ace4084de70c7a75d4ad1f Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Tue, 23 Aug 2022 01:01:29 +0200 Subject: [PATCH] PeerMonitor: simplify getAddressForPeer() with trinary operator --- .../main/java/org/bitcoinj/examples/PeerMonitor.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/examples/src/main/java/org/bitcoinj/examples/PeerMonitor.java b/examples/src/main/java/org/bitcoinj/examples/PeerMonitor.java index e5bf14152..49b120ab9 100644 --- a/examples/src/main/java/org/bitcoinj/examples/PeerMonitor.java +++ b/examples/src/main/java/org/bitcoinj/examples/PeerMonitor.java @@ -252,13 +252,11 @@ public class PeerMonitor { } } - private Object getAddressForPeer(Peer peer) { - String s; - s = reverseDnsLookups.get(peer); - if (s != null) - return s; - else - return peer.getAddress().getAddr().getHostAddress(); + private String getAddressForPeer(Peer peer) { + String s = reverseDnsLookups.get(peer); + return (s != null) + ? s + : peer.getAddress().getAddr().getHostAddress(); } private String getAddressesForPeer(Peer peer) {