From d7f3f27348ad7daf03baf3f851f404a66d034804 Mon Sep 17 00:00:00 2001 From: Matthias Jaros Date: Wed, 5 Aug 2026 00:19:16 +0200 Subject: Resolved data/object asymmetry by using methods and an inner class --- src/main/java/com/it_jaros/jscanner/Scan.java | 46 +++++++++++++++------------ 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'src/main/java/com/it_jaros/jscanner/Scan.java') diff --git a/src/main/java/com/it_jaros/jscanner/Scan.java b/src/main/java/com/it_jaros/jscanner/Scan.java index dc109c6..9b3bf5e 100644 --- a/src/main/java/com/it_jaros/jscanner/Scan.java +++ b/src/main/java/com/it_jaros/jscanner/Scan.java @@ -96,27 +96,11 @@ public class Scan { onDone.run(); } - public Counter getThreadCounter() { - return threadCounter; - } - - public Counter getHostCounter() { - return hostCounter; - } - - public Counter getSocketCounter() { - return socketCounter; - } - - public Counter getHostTotalCounter() { - return hostTotalCounter; - } - public void start() { start = System.currentTimeMillis(); } - public long getDurationMillis() { + private long getDurationMillis() { if (stop == 0) { if (start == 0) { return 0; @@ -162,7 +146,29 @@ public class Scan { this.threadCounter.dec(); } - public int portTotal() { - return this.portTotalCounter.current(); - } + public Statistics getStatistics() { + return new Statistics( + this.getDurationMillis(), + this.hostTotalCounter.current(), + this.hostCounter.current(), + this.hostCounter.max(), + this.portTotalCounter.current(), + this.threadCounter.current(), + this.threadCounter.max(), + this.socketCounter.current(), + this.socketCounter.max() + ); + } + + public record Statistics( + long durationInMillis, + int hostTotal, + int hostCurrent, + int hostMaxConcurrent, + int portTotal, + int threadCurrent, + int threadMaxConcurrent, + int socketCurrent, + int socketMaxConcurrent + ) {} } -- cgit v1.3.1