From: Kai Moritz Date: Sun, 8 Jan 2023 09:17:34 +0000 (+0100) Subject: refactore: Renamed `ChatroomFactory` to `ChatHomeService` -- Move X-Git-Tag: wip~73 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=082c283842990180b23f8a35fb3dfa4ebc8a5189;p=demos%2Fkafka%2Fchat refactore: Renamed `ChatroomFactory` to `ChatHomeService` -- Move --- diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java new file mode 100644 index 00000000..e1236b9a --- /dev/null +++ b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatHomeService.java @@ -0,0 +1,9 @@ +package de.juplo.kafka.chat.backend.domain; + +import java.util.UUID; + + +public interface ChatroomFactory +{ + Chatroom createChatroom(UUID id, String name); +} diff --git a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatroomFactory.java b/src/main/java/de/juplo/kafka/chat/backend/domain/ChatroomFactory.java deleted file mode 100644 index e1236b9a..00000000 --- a/src/main/java/de/juplo/kafka/chat/backend/domain/ChatroomFactory.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.juplo.kafka.chat.backend.domain; - -import java.util.UUID; - - -public interface ChatroomFactory -{ - Chatroom createChatroom(UUID id, String name); -} diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java new file mode 100644 index 00000000..41ecd4cf --- /dev/null +++ b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatHomeService.java @@ -0,0 +1,32 @@ +package de.juplo.kafka.chat.backend.persistence; + +import de.juplo.kafka.chat.backend.domain.Chatroom; +import de.juplo.kafka.chat.backend.domain.ChatroomFactory; +import lombok.RequiredArgsConstructor; + +import java.util.LinkedHashMap; +import java.util.UUID; + + +@RequiredArgsConstructor +public class InMemoryChatroomFactory implements ChatroomFactory +{ + private final int bufferSize; + + + @Override + public Chatroom createChatroom(UUID id, String name) + { + InMemoryChatroomService chatroomService = + new InMemoryChatroomService(new LinkedHashMap<>()); + return new Chatroom(id, name, chatroomService, bufferSize); + } + + public Chatroom restoreChatroom( + UUID id, + String name, + InMemoryChatroomService chatroomService) + { + return new Chatroom(id, name, chatroomService, bufferSize); + } +} diff --git a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatroomFactory.java b/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatroomFactory.java deleted file mode 100644 index 41ecd4cf..00000000 --- a/src/main/java/de/juplo/kafka/chat/backend/persistence/InMemoryChatroomFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package de.juplo.kafka.chat.backend.persistence; - -import de.juplo.kafka.chat.backend.domain.Chatroom; -import de.juplo.kafka.chat.backend.domain.ChatroomFactory; -import lombok.RequiredArgsConstructor; - -import java.util.LinkedHashMap; -import java.util.UUID; - - -@RequiredArgsConstructor -public class InMemoryChatroomFactory implements ChatroomFactory -{ - private final int bufferSize; - - - @Override - public Chatroom createChatroom(UUID id, String name) - { - InMemoryChatroomService chatroomService = - new InMemoryChatroomService(new LinkedHashMap<>()); - return new Chatroom(id, name, chatroomService, bufferSize); - } - - public Chatroom restoreChatroom( - UUID id, - String name, - InMemoryChatroomService chatroomService) - { - return new Chatroom(id, name, chatroomService, bufferSize); - } -}