From 93f9e5cea5fb73d35d6df60518533cdd7cc9d12d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Wed, 28 Dec 2022 17:20:53 +0100 Subject: [PATCH] feat: `Chatroom.getMessages()` is fully paginated (takes first and last) --- .../java/de/juplo/kafka/chat/backend/domain/Chatroom.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java b/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java index 62c97327..115dcd69 100644 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/Chatroom.java @@ -72,12 +72,16 @@ public class Chatroom return sink.asFlux(); } - public Stream getMessages(long firstMessage) + public Stream getMessages(long first, long last) { return messages .values() .stream() - .filter(message -> message.getSerialNumber() >= firstMessage); + .filter(message -> + { + long serial = message.getSerialNumber(); + return serial >= first && serial <= last; + }); } -- 2.20.1