1 package de.juplo.kafka.chat.backend.domain;
3 import lombok.RequiredArgsConstructor;
6 import java.util.stream.Stream;
9 @RequiredArgsConstructor
12 private final Map<UUID, Chatroom> chatrooms;
13 private final ChatroomFactory factory;
16 public Chatroom createChatroom(String name)
18 Chatroom chatroom = factory.createChatroom(UUID.randomUUID(), name);
19 chatrooms.put(chatroom.getId(), chatroom);
23 public Optional<Chatroom> getChatroom(UUID id)
25 return Optional.ofNullable(chatrooms.get(id));
28 public Stream<Chatroom> list()
30 return chatrooms.values().stream();