From e12775b6aef0b6f09d209b630efe6085625041ac Mon Sep 17 00:00:00 2001 From: Stefan Kalscheuer Date: Tue, 29 Aug 2017 18:26:51 +0200 Subject: [PATCH] Refactored empty-checks on result lists --- src/main/java/de/stklcode/pubtrans/ura/UraClient.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/stklcode/pubtrans/ura/UraClient.java b/src/main/java/de/stklcode/pubtrans/ura/UraClient.java index 35461c5..ecfbab7 100644 --- a/src/main/java/de/stklcode/pubtrans/ura/UraClient.java +++ b/src/main/java/de/stklcode/pubtrans/ura/UraClient.java @@ -223,7 +223,7 @@ public class UraClient { while (line != null && (limit == null || trips.size() < limit)) { List l = mapper.readValue(line, List.class); /* Check if result exists and has correct response type */ - if (l != null && l.size() > 0) { + if (l != null && !l.isEmpty()) { if (l.get(0).equals(RES_TYPE_URA_VERSION)) { version = l.get(1).toString(); } else if (l.get(0).equals(RES_TYPE_PREDICTION)) { @@ -259,11 +259,10 @@ public class UraClient { try (InputStream is = requestInstant(REQUEST_STOP, query); BufferedReader br = new BufferedReader(new InputStreamReader(is))) { String line; - String version; while ((line = br.readLine()) != null) { List l = mapper.readValue(line, List.class); /* Check if result exists and has correct response type */ - if (l != null && l.size() > 0 && l.get(0).equals(RES_TYPE_STOP)) { + if (l != null && !l.isEmpty() && l.get(0).equals(RES_TYPE_STOP)) { stops.add(new Stop(l)); } }