1 package de.juplo.kafka.chat.backend.domain;
3 import lombok.RequiredArgsConstructor;
8 @RequiredArgsConstructor
11 private final Map<UUID, Chatroom> chatrooms;
12 private final ChatroomFactory factory;
15 public Chatroom createChatroom(String name)
17 Chatroom chatroom = factory.createChatroom(UUID.randomUUID(), name);
18 chatrooms.put(chatroom.getId(), chatroom);
22 public Optional<Chatroom> getChatroom(UUID id)
24 return Optional.ofNullable(chatrooms.get(id));
27 public Collection<Chatroom> list()
29 return chatrooms.values();